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
86 lines
2.8 KiB
Plaintext
86 lines
2.8 KiB
Plaintext
// Copyright (c) Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
An example to explore achieved occupancy, and various occupancy limiters.
|
|
Written by Nicholas Curtis [AMD].
|
|
*/
|
|
|
|
#include "common.h"
|
|
|
|
__global__ void empty(int N, double* ptr) {
|
|
|
|
}
|
|
|
|
constexpr int bound = 16;
|
|
__launch_bounds__(256)
|
|
__global__ void vgprbound(int N, double* ptr) {
|
|
double intermediates[bound];
|
|
for (int i = 0 ; i < bound; ++i) intermediates[i] = N * threadIdx.x;
|
|
double x = ptr[threadIdx.x];
|
|
for (int i = 0; i < 100; ++i) {
|
|
x += sin(pow(__shfl(x, i % warpSize) * intermediates[(i - 1) % bound], intermediates[i % bound]));
|
|
intermediates[i % bound] = x;
|
|
}
|
|
if (x == N) ptr[threadIdx.x] = x;
|
|
}
|
|
|
|
constexpr size_t fully_allocate_lds = 64ul * 1024ul / sizeof(double);
|
|
__launch_bounds__(256)
|
|
__global__ void ldsbound(int N, double* ptr) {
|
|
__shared__ double intermediates[fully_allocate_lds];
|
|
for (int i = threadIdx.x ; i < fully_allocate_lds; i += blockDim.x) intermediates[i] = N * threadIdx.x;
|
|
__syncthreads();
|
|
double x = ptr[threadIdx.x];
|
|
for (int i = threadIdx.x; i < fully_allocate_lds; i += blockDim.x) {
|
|
x += sin(pow(__shfl(x, i % warpSize) * intermediates[(i - 1) % fully_allocate_lds], intermediates[i % fully_allocate_lds]));
|
|
__syncthreads();
|
|
intermediates[i % fully_allocate_lds] = x;
|
|
}
|
|
if (x == N) ptr[threadIdx.x] = x;
|
|
}
|
|
|
|
constexpr int sgprlim = 1;
|
|
__launch_bounds__(1024, 8)
|
|
__global__ void sgprbound(int N, double* ptr) {
|
|
double intermediates[sgprlim];
|
|
for (int i = 0 ; i < sgprlim; ++i) intermediates[i] = i;
|
|
double x = ptr[0];
|
|
#pragma unroll 1
|
|
for (int i = 0; i < 100; ++i) {
|
|
x += sin(pow(intermediates[(i - 1) % sgprlim], intermediates[i % sgprlim]));
|
|
intermediates[i % sgprlim] = x;
|
|
}
|
|
if (x == N) ptr[0] = x;
|
|
}
|
|
|
|
int main() {
|
|
double* ptr;
|
|
hipCheck(hipMalloc(&ptr, 1024 * sizeof(double)));
|
|
vgprbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
vgprbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
ldsbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
ldsbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
sgprbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
sgprbound<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
empty<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
empty<<<1024 * 1024, 256>>>(0, ptr);
|
|
hipCheck(hipGetLastError());
|
|
hipCheck(hipDeviceSynchronize());
|
|
hipCheck(hipFree(ptr));
|
|
}
|