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
95 lines
2.7 KiB
C++
95 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <chrono>
|
|
#include <hip_test_common.hh>
|
|
|
|
using namespace std;
|
|
|
|
__global__ static void _noop_kernel() {}
|
|
|
|
|
|
HIP_TEST_CASE(Performance_KernelLaunchLatency_IncreasingNumberOfStreams) {
|
|
vector<int> streamsNumber{1, 10, 50, 100, 1000, 5000};
|
|
hipError_t err = hipSuccess;
|
|
hipEvent_t start, stop;
|
|
int32_t NITER = 100000;
|
|
|
|
bool isBlocking = true;
|
|
bool launchOnNullStream = true;
|
|
|
|
SECTION("BlockingStreams, KernelLaunchOnNullStream") {
|
|
std::cout << "BlockingStreams, LaunchOnNullStream" << std::endl;
|
|
isBlocking = true;
|
|
launchOnNullStream = true;
|
|
}
|
|
|
|
SECTION("BlockingStreams, KernelLaunchOnCreatedStream") {
|
|
std::cout << "BlockingStreams, LaunchOnCreatedStream" << std::endl;
|
|
isBlocking = true;
|
|
launchOnNullStream = false;
|
|
}
|
|
|
|
SECTION("NonBlockingStreams, KernelLaunchOnNullStream") {
|
|
std::cout << "NonBlockingStreams, LaunchOnNullStream" << std::endl;
|
|
isBlocking = false;
|
|
launchOnNullStream = true;
|
|
}
|
|
|
|
SECTION("NonBlockingStreams, KernelLaunchOnCreatedStream") {
|
|
std::cout << "NonBlockingStreams, LaunchOnCreatedStream" << std::endl;
|
|
isBlocking = false;
|
|
launchOnNullStream = false;
|
|
}
|
|
|
|
HIP_CHECK(hipEventCreate(&start));
|
|
HIP_CHECK(hipEventCreate(&stop));
|
|
|
|
for (auto& numHipStreams : streamsNumber) {
|
|
vector<hipStream_t> streams(numHipStreams);
|
|
|
|
if (isBlocking) {
|
|
for (int i = 0; i < numHipStreams; ++i) {
|
|
HIP_CHECK(hipStreamCreate(&streams[i]));
|
|
}
|
|
} else {
|
|
for (int i = 0; i < numHipStreams; ++i) {
|
|
HIP_CHECK(hipStreamCreateWithFlags(&streams[i], hipStreamNonBlocking));
|
|
}
|
|
}
|
|
|
|
auto kernelStart = std::chrono::steady_clock::now();
|
|
for (int i = 0; i < NITER; ++i) {
|
|
if (launchOnNullStream) {
|
|
HIP_CHECK(hipEventRecord(start, NULL));
|
|
_noop_kernel<<<1, 1>>>();
|
|
HIP_CHECK(hipEventRecord(stop, NULL));
|
|
} else {
|
|
HIP_CHECK(hipEventRecord(start, streams[0]));
|
|
_noop_kernel<<<1, 1, 0, streams[0]>>>();
|
|
HIP_CHECK(hipEventRecord(stop, streams[0]));
|
|
}
|
|
do {
|
|
err = hipEventQuery(stop);
|
|
} while (err == hipErrorNotReady);
|
|
}
|
|
auto kernelStop = std::chrono::steady_clock::now();
|
|
double usec = std::chrono::duration<double, std::micro>(kernelStop - kernelStart).count();
|
|
|
|
cout << "hipLaunchKernel average duration with " << numHipStreams
|
|
<< " streams: " << usec / NITER << " us" << std::endl;
|
|
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
for (int i = 0; i < numHipStreams; ++i) {
|
|
HIP_CHECK(hipStreamDestroy(streams[i]));
|
|
}
|
|
}
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(stop));
|
|
}
|