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
99 lines
2.3 KiB
C++
99 lines
2.3 KiB
C++
#include "hip/hip_runtime_api.h"
|
|
#include <hip_test_common.hh>
|
|
|
|
#ifdef _WIN32
|
|
#define MAX_BURST_SIZE 40
|
|
#else
|
|
#define MAX_BURST_SIZE 100
|
|
#endif
|
|
|
|
// Create a lot of streams and then destroy 'em.
|
|
void createThenDestroyStreams(int iterations, int burstSize) {
|
|
hipStream_t* streams = new hipStream_t[burstSize];
|
|
|
|
for (int i = 0; i < iterations; i++) {
|
|
for (int j = 0; j < burstSize; j++) {
|
|
HIPCHECK(hipStreamCreate(&streams[j]));
|
|
}
|
|
for (int j = 0; j < burstSize; j++) {
|
|
HIPCHECK(hipStreamDestroy(streams[j]));
|
|
}
|
|
}
|
|
|
|
delete[] streams;
|
|
}
|
|
|
|
|
|
void waitStreams(int iterations) {
|
|
// Repeatedly sync and wait for all streams to complete.
|
|
// TO make this interesting, the test has other threads repeatedly adding and removing streams
|
|
// to the device.
|
|
for (int i = 0; i < iterations; i++) {
|
|
HIPCHECK(hipDeviceSynchronize());
|
|
}
|
|
}
|
|
|
|
|
|
// Create 3 streams, all creating and destroying streams on the same device.
|
|
// Some create many queue, some not many.
|
|
//
|
|
void multiThread_pyramid(bool serialize, int iters) {
|
|
std::thread t1(createThenDestroyStreams, iters * 1, MAX_BURST_SIZE);
|
|
if (serialize) {
|
|
t1.join();
|
|
}
|
|
|
|
std::thread t2(createThenDestroyStreams, iters * 10, 10);
|
|
if (serialize) {
|
|
t2.join();
|
|
}
|
|
|
|
std::thread t3(createThenDestroyStreams, iters * 100, 1);
|
|
if (serialize) {
|
|
t3.join();
|
|
}
|
|
|
|
if (!serialize) {
|
|
t1.join();
|
|
t2.join();
|
|
t3.join();
|
|
}
|
|
}
|
|
|
|
|
|
// Create 3 streams, all creating and destroying streams on the same device.
|
|
// Try to keep number of streams near zero, to cause problems.
|
|
void multiThread_nearzero(bool serialize, int iters) {
|
|
std::thread t1(createThenDestroyStreams, iters, 1);
|
|
if (serialize) {
|
|
t1.join();
|
|
}
|
|
|
|
std::thread t2(createThenDestroyStreams, iters, 1);
|
|
if (serialize) {
|
|
t2.join();
|
|
}
|
|
|
|
std::thread t3(waitStreams, iters * 50);
|
|
if (serialize) {
|
|
t3.join();
|
|
}
|
|
|
|
if (!serialize) {
|
|
t1.join();
|
|
t2.join();
|
|
t3.join();
|
|
}
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipMultiThreadDevice_Streams) {
|
|
// Serial version, just call once:
|
|
createThenDestroyStreams(10, 10);
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipMultiThreadDevice_SerialPyramid) { multiThread_pyramid(true, 3); }
|
|
|
|
HIP_TEST_CASE(Unit_hipMultiThreadDevice_ParallelPyramid) { multiThread_pyramid(false, 3); }
|
|
|
|
HIP_TEST_CASE(Unit_hipMultiThreadDevice_NearZero) { multiThread_nearzero(false, 1000); }
|