Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

109 lines
3.8 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include "kernel_launch_common.hh"
#include <hip_test_common.hh>
/**
* @addtogroup kernelLaunch kernel launch
* @{
* @ingroup PerformanceTestKernelLaunch
* Contains performance tests for kernel launch overhead benchmarking.
*/
template <KernelType kernel_type, bool timer_type> class ExtLaunchKernelBenchmark
: public KernelLaunchBenchmark<ExtLaunchKernelBenchmark<kernel_type, timer_type>, timer_type> {
public:
constexpr void LaunchKernel() {
if constexpr (kernel_type == KernelType::kNull) {
error_ = hipExtLaunchKernel(reinterpret_cast<void*>(NullKernel), 1, 1, nullptr, 0, nullptr,
events_[0], events_[1], 0u);
} else if constexpr (kernel_type == KernelType::kSmall) {
error_ = hipExtLaunchKernel(reinterpret_cast<void*>(KernelWithSmallArgs), 1, 1,
small_kernel_args_, 0, nullptr, events_[0], events_[1], 0u);
} else if constexpr (kernel_type == KernelType::kMedium) {
error_ = hipExtLaunchKernel(reinterpret_cast<void*>(KernelWithMediumArgs), 1, 1,
medium_kernel_args_, 0, nullptr, events_[0], events_[1], 0u);
} else if constexpr (kernel_type == KernelType::kLarge) {
error_ = hipExtLaunchKernel(reinterpret_cast<void*>(KernelWithLargeArgs), 1, 1,
large_kernel_args_, 0, nullptr, events_[0], events_[1], 0u);
} else
;
}
hipError_t GetError() { return error_; }
private:
EventsGuard events_{2};
hipError_t error_;
char* out_ = nullptr;
void* small_kernel_args_[2] = {&small_kernel_args, &out_};
void* medium_kernel_args_[2] = {&medium_kernel_args, &out_};
void* large_kernel_args_[2] = {&large_kernel_args, &out_};
};
template <KernelType kernel_type, bool timer_type> static void RunBenchmark(bool sync) {
ExtLaunchKernelBenchmark<kernel_type, timer_type> benchmark;
benchmark.AddSectionName(GetSynchronizationSectionName(sync));
benchmark.AddSectionName(GetKernelTypeSectionName<kernel_type>());
benchmark.AddSectionName(GetTimerTypeSectionName<timer_type>());
benchmark.Run(sync);
HIP_CHECK(benchmark.GetError());
}
/**
* Test Description
* ------------------------
* - Calls an empty kernel using hipExtLaunchKernel:
* -# With different timing methods:
* - CPU-based
* - Event-based
* -# With different synchronization behavior:
* - Using a stream synchronization between each iteration
* - Without any synchronization between iterations
* -# With different kernel argument sizes
* Test source
* ------------------------
* - performance/api/kernelLaunch/hipExtLaunchKernel.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
HIP_TEST_CASE(Performance_hipExtLaunchKernel) {
bool sync = GENERATE(true, false);
SECTION("null kernel") {
SECTION("cpu-based timing") { RunBenchmark<KernelType::kNull, kTimerTypeCpu>(sync); }
SECTION("event-based timing") { RunBenchmark<KernelType::kNull, kTimerTypeEvent>(sync); }
}
SECTION("small kernel") {
SECTION("cpu-based timing") { RunBenchmark<KernelType::kSmall, kTimerTypeCpu>(sync); }
SECTION("event-based timing") { RunBenchmark<KernelType::kSmall, kTimerTypeEvent>(sync); }
}
SECTION("medium kernel") {
SECTION("cpu-based timing") { RunBenchmark<KernelType::kMedium, kTimerTypeCpu>(sync); }
SECTION("event-based timing") { RunBenchmark<KernelType::kMedium, kTimerTypeEvent>(sync); }
}
SECTION("large kernel") {
SECTION("cpu-based timing") { RunBenchmark<KernelType::kLarge, kTimerTypeCpu>(sync); }
SECTION("event-based timing") { RunBenchmark<KernelType::kLarge, kTimerTypeEvent>(sync); }
}
}
/**
* End doxygen group kernelLaunch.
* @}
*/