SWDEV-491253 - Create stream capture test for kernel APIs (#1189)
Этот коммит содержится в:
@@ -188,8 +188,6 @@ TEST_CASE("Unit_hipExtLaunchKernel_Negative_Parameters") {
|
||||
* - HIP_VERSION >= 6.0
|
||||
*/
|
||||
TEST_CASE("Unit_hipExtLaunchKernel_capturehipExtLaunchKernel") {
|
||||
hipGraph_t graph{nullptr};
|
||||
hipGraphExec_t graphExec{nullptr};
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
int* A_d;
|
||||
@@ -197,24 +195,21 @@ TEST_CASE("Unit_hipExtLaunchKernel_capturehipExtLaunchKernel") {
|
||||
A_h = reinterpret_cast<int*>(malloc(sizeof(int)));
|
||||
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&A_d), sizeof(int)));
|
||||
void* args[1] = {&A_d};
|
||||
|
||||
// Begin Capture operation
|
||||
HIP_CHECK(hipStreamBeginCapture(stream, hipStreamCaptureModeGlobal));
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
HIP_CHECK(hipExtLaunchKernel(reinterpret_cast<void*>(kernel_42), dim3{1, 1, 1}, dim3{1, 1, 1},
|
||||
args, 0, stream, nullptr, nullptr, 0u));
|
||||
// End Capture
|
||||
HIP_CHECK(hipStreamEndCapture(stream, &graph));
|
||||
END_CAPTURE(stream);
|
||||
|
||||
// Create and Launch Executable Graphs
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
HIP_CHECK(hipMemcpyDtoH(A_h, A_d, sizeof(int)));
|
||||
REQUIRE(A_h != nullptr);
|
||||
REQUIRE(*A_h == 42);
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
HIP_CHECK(hipFree(A_d));
|
||||
free(A_h);
|
||||
|
||||
@@ -177,3 +177,22 @@ TEST_CASE("Unit_hipLaunchCooperativeKernel_Negative_Parameters") {
|
||||
hipErrorCooperativeLaunchTooLarge);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipLaunchCooperativeKernel_Verify_Capture") {
|
||||
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
|
||||
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
HIP_CHECK(hipLaunchCooperativeKernel(reinterpret_cast<void*>(coop_kernel), dim3{2, 2, 1},
|
||||
dim3{1, 1, 1}, nullptr, 0, stream));
|
||||
END_CAPTURE(stream);
|
||||
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
@@ -155,4 +155,18 @@ TEST_CASE("Unit_hipLaunchKernel_Negative_Parameters") {
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipLaunchKernel_Verify_Capture") {
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
HIP_CHECK(hipLaunchKernel(reinterpret_cast<void*>(kernel), dim3{1, 1, 1}, dim3{1, 1, 1}, nullptr,
|
||||
0, stream));
|
||||
END_CAPTURE(stream);
|
||||
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
@@ -66,4 +66,24 @@ TEST_CASE("Unit___hipPushCallConfiguration_Positive_Basic") {
|
||||
REQUIRE(block.z == 1);
|
||||
REQUIRE(shmem == 1024);
|
||||
REQUIRE(stream == stream_guard.stream());
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipLaunchByPtr_Verify_Capture") {
|
||||
LinearAllocGuard<int> alloc(LinearAllocs::hipMallocManaged, 4);
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
|
||||
HIP_CHECK(hipConfigureCall(dim3{1}, dim3{1}, 0, stream));
|
||||
int* arg = alloc.ptr();
|
||||
HIP_CHECK(hipSetupArgument(&arg, sizeof(int*), 0));
|
||||
HIP_CHECK(hipLaunchByPtr(reinterpret_cast<void*>(kernel_42)));
|
||||
|
||||
END_CAPTURE(stream);
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
|
||||
REQUIRE(alloc.ptr()[0] == 42);
|
||||
}
|
||||
@@ -213,6 +213,39 @@ TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Negative_Parameters") {
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test `hipModuleLaunchCooperativeKernel` when it is captured.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/module/hipModuleLaunchCooperativeKernel.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.5
|
||||
*/
|
||||
TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Verify_Capture") {
|
||||
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
|
||||
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
|
||||
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
|
||||
hipFunction_t f = GetKernel(mg.module(), "CoopKernel");
|
||||
HIP_CHECK(hipModuleLaunchCooperativeKernel(f, 2, 2, 1, 1, 1, 1, 0, stream, nullptr));
|
||||
|
||||
END_CAPTURE(stream);
|
||||
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* End doxygen group ModuleTest.
|
||||
* @}
|
||||
|
||||
@@ -318,3 +318,21 @@ TEST_CASE("Unit_hipModuleLaunchKernel_Fntl") {
|
||||
REQUIRE(testStatus == true);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLaunchKernel_Verify_Capture") {
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
|
||||
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
|
||||
|
||||
GENERATE_CAPTURE();
|
||||
BEGIN_CAPTURE(stream);
|
||||
|
||||
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
|
||||
HIP_CHECK(hipModuleLaunchKernel(f, 1, 1, 1, 1, 1, 1, 0, stream, nullptr, nullptr));
|
||||
|
||||
END_CAPTURE(stream);
|
||||
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user