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
121 lines
4.2 KiB
C++
121 lines
4.2 KiB
C++
//===------- Offload API tests - olLaunchKernel Cooperative ---------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "../common/Fixtures.hpp"
|
|
#include <OffloadAPI.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
struct olLaunchKernelCooperativeTest : LaunchSingleKernelTestBase {
|
|
void SetUp() override {
|
|
SetUpKernel("noargs");
|
|
|
|
bool SupportsCooperative = false;
|
|
auto Result =
|
|
olGetDeviceInfo(Device, OL_DEVICE_INFO_COOPERATIVE_LAUNCH_SUPPORT,
|
|
sizeof(bool), &SupportsCooperative);
|
|
|
|
if (Result) {
|
|
if (Result->Code == OL_ERRC_UNIMPLEMENTED) {
|
|
GTEST_SKIP()
|
|
<< "Device does not provide cooperative launch support information";
|
|
}
|
|
if (Result->Code != OL_ERRC_SUCCESS) {
|
|
GTEST_FAIL() << "olGetDeviceInfo failed with unexpected error: "
|
|
<< Result->Code << ": " << Result->Details;
|
|
}
|
|
}
|
|
|
|
if (!SupportsCooperative) {
|
|
GTEST_SKIP() << "Device does not support cooperative kernel launch";
|
|
}
|
|
}
|
|
};
|
|
OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olLaunchKernelCooperativeTest);
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, GetMaxCooperativeGroupCount) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_SUCCESS(olGetKernelMaxCooperativeGroupCount(
|
|
Device, Kernel, &LaunchArgs, &MaxGroupCount));
|
|
ASSERT_GT(MaxGroupCount, 0u);
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, SuccessCooperative) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_SUCCESS(olGetKernelMaxCooperativeGroupCount(
|
|
Device, Kernel, &LaunchArgs, &MaxGroupCount));
|
|
|
|
LaunchArgs.NumGroups.x = MaxGroupCount;
|
|
|
|
bool IsCooperative = true;
|
|
ol_kernel_launch_prop_t Props[] = {
|
|
{OL_KERNEL_LAUNCH_PROP_TYPE_IS_COOPERATIVE, &IsCooperative},
|
|
OL_KERNEL_LAUNCH_PROP_END};
|
|
|
|
ASSERT_SUCCESS(olLaunchKernel(Queue, Device, Kernel, &LaunchArgs, Props, 0,
|
|
nullptr, nullptr));
|
|
ASSERT_SUCCESS(olSyncQueue(Queue));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, SuccessNonCooperative) {
|
|
ASSERT_SUCCESS(olLaunchKernel(Queue, Device, Kernel, &LaunchArgs, nullptr, 0,
|
|
nullptr, nullptr));
|
|
ASSERT_SUCCESS(olSyncQueue(Queue));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, TooManyGroups) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_SUCCESS(olGetKernelMaxCooperativeGroupCount(
|
|
Device, Kernel, &LaunchArgs, &MaxGroupCount));
|
|
|
|
LaunchArgs.NumGroups.x = MaxGroupCount * 2;
|
|
|
|
bool IsCooperative = true;
|
|
ol_kernel_launch_prop_t Props[] = {
|
|
{OL_KERNEL_LAUNCH_PROP_TYPE_IS_COOPERATIVE, &IsCooperative},
|
|
OL_KERNEL_LAUNCH_PROP_END};
|
|
|
|
ASSERT_ANY_ERROR(olLaunchKernel(Queue, Device, Kernel, &LaunchArgs, Props, 0,
|
|
nullptr, nullptr));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, SynchronousLaunch) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_SUCCESS(olGetKernelMaxCooperativeGroupCount(
|
|
Device, Kernel, &LaunchArgs, &MaxGroupCount));
|
|
|
|
LaunchArgs.NumGroups.x = std::min(MaxGroupCount, 2u);
|
|
|
|
bool IsCooperative = true;
|
|
ol_kernel_launch_prop_t Props[] = {
|
|
{OL_KERNEL_LAUNCH_PROP_TYPE_IS_COOPERATIVE, &IsCooperative},
|
|
OL_KERNEL_LAUNCH_PROP_END};
|
|
|
|
ASSERT_SUCCESS(olLaunchKernel(nullptr, Device, Kernel, &LaunchArgs, Props, 0,
|
|
nullptr, nullptr));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, InvalidNullHandleKernel) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_ERROR(OL_ERRC_INVALID_NULL_HANDLE,
|
|
olGetKernelMaxCooperativeGroupCount(Device, nullptr, &LaunchArgs,
|
|
&MaxGroupCount));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, InvalidNullHandleDevice) {
|
|
uint32_t MaxGroupCount = 0;
|
|
ASSERT_ERROR(OL_ERRC_INVALID_NULL_HANDLE,
|
|
olGetKernelMaxCooperativeGroupCount(nullptr, Kernel, &LaunchArgs,
|
|
&MaxGroupCount));
|
|
}
|
|
|
|
TEST_P(olLaunchKernelCooperativeTest, InvalidNullPointerGroupCountRet) {
|
|
ASSERT_ERROR(OL_ERRC_INVALID_NULL_POINTER,
|
|
olGetKernelMaxCooperativeGroupCount(Device, Kernel, &LaunchArgs,
|
|
nullptr));
|
|
}
|