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
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
#include "test_framework.hpp"
|
|
#include <vector>
|
|
|
|
// LDS bank conflict test - stride-32 access pattern
|
|
// Targets SQ_LDS_BANK_CONFLICT counter
|
|
__global__ void lds_conflicts_kernel(float* output, const float* input) {
|
|
__shared__ float shared_mem[1024];
|
|
|
|
int tid = threadIdx.x;
|
|
int gid = blockIdx.x * blockDim.x + threadIdx.x;
|
|
|
|
// Write with stride to cause bank conflicts
|
|
// On AMD GPUs, LDS has 32 banks
|
|
int write_idx = (tid * 32) % 1024;
|
|
shared_mem[write_idx] = input[gid];
|
|
__syncthreads();
|
|
|
|
// Read with stride to cause bank conflicts
|
|
int read_idx = (tid * 32 + 1) % 1024;
|
|
float val = shared_mem[read_idx];
|
|
|
|
// Multiple rounds of conflicting access
|
|
for (int i = 0; i < 10; i++) {
|
|
write_idx = ((tid + i) * 32) % 1024;
|
|
shared_mem[write_idx] = val * 1.01f;
|
|
__syncthreads();
|
|
|
|
read_idx = ((tid + i + 1) * 32) % 1024;
|
|
val = shared_mem[read_idx];
|
|
__syncthreads();
|
|
}
|
|
|
|
output[gid] = val;
|
|
}
|
|
|
|
class LDSConflictsTest : public test_framework::TestBase {
|
|
public:
|
|
LDSConflictsTest() : TestBase("LDS Conflicts - Bank Conflicts") {}
|
|
|
|
bool setup() override {
|
|
size_ = 256 * 1024; // 256K elements
|
|
|
|
// 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 << " LDS size per block: 1024 floats (4 KB)" << std::endl;
|
|
std::cout << " Access pattern: stride-32 (causes bank conflicts)" << std::endl;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool execute() override {
|
|
dim3 block_size(256);
|
|
dim3 grid_size(size_ / block_size.x);
|
|
|
|
test_framework::KernelRunner runner("lds_conflicts_kernel", grid_size, block_size);
|
|
runner.launch(lds_conflicts_kernel, d_output_, d_input_);
|
|
|
|
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 main() {
|
|
LDSConflictsTest test;
|
|
return test.run();
|
|
}
|