Files
TheRock/rocm-systems/experimental/perf-dkms/test_apps/waits_stalls/waits_stalls.cpp
T
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

80 lines
2.2 KiB
C++

#include "test_framework.hpp"
#include <vector>
// Kernel designed to create memory wait states and stalls
// Targets GRBM_* wait/stall counters
__global__ void waits_stalls_kernel(float* output, const float* input, int iterations) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
float val = 0.0f;
// Create memory dependencies that cause stalls
for (int i = 0; i < iterations; i++) {
// Read that creates dependency
float temp = input[(idx + i) % (blockDim.x * gridDim.x)];
// Immediate use creates stall waiting for memory
val = temp * temp + temp;
// Another dependent read
temp = input[(idx + (int)(val * 13)) % (blockDim.x * gridDim.x)];
// More dependency
val = val + temp;
// Write that depends on previous operations
output[idx] = val;
// Sync to create more stalls
__syncthreads();
}
output[idx] = val;
}
class WaitsStallsTest : public test_framework::TestBase {
public:
WaitsStallsTest() : TestBase("Waits/Stalls - Memory Dependencies") {}
bool setup() override {
size_ = 256 * 1024; // 256K elements
iterations_ = 100;
// Allocate device memory
d_input_ = hip_utils::allocateDeviceWithValue<float>(size_, 1.0f);
d_output_ = hip_utils::allocateDevice<float>(size_);
std::cout << " Array size: " << size_ << " elements" << std::endl;
std::cout << " Iterations: " << iterations_ << std::endl;
std::cout << " Expected behavior: Memory wait states and stalls" << std::endl;
return true;
}
bool execute() override {
dim3 block_size(256);
dim3 grid_size((size_ + block_size.x - 1) / block_size.x);
test_framework::KernelRunner runner("waits_stalls_kernel", grid_size, block_size);
runner.launch(waits_stalls_kernel, d_output_, d_input_, iterations_);
return true;
}
void cleanup() override {
hip_utils::freeDevice(d_input_);
hip_utils::freeDevice(d_output_);
}
private:
float* d_input_ = nullptr;
float* d_output_ = nullptr;
size_t size_;
int iterations_;
};
int main() {
WaitsStallsTest test;
return test.run();
}