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
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <hip_test_common.hh>
|
|
#include <hip/hip_cooperative_groups.h>
|
|
#include <hip/cooperative_groups/hip_reduce.h>
|
|
#include <hip/cooperative_groups/hip_scan.h>
|
|
#include <cmd_options.hh>
|
|
#include "../math/math_common.hh"
|
|
namespace {
|
|
constexpr int kMaxGPUs = 8;
|
|
} // namespace
|
|
|
|
constexpr int MaxGPUs = 8;
|
|
|
|
inline bool operator==(const dim3& l, const dim3& r) {
|
|
return l.x == r.x && l.y == r.y && l.z == r.z;
|
|
}
|
|
|
|
inline bool operator!=(const dim3& l, const dim3& r) { return !(l == r); }
|
|
|
|
__device__ inline unsigned int thread_rank_in_grid() {
|
|
const auto block_size = blockDim.x * blockDim.y * blockDim.z;
|
|
const auto block_rank_in_grid = (blockIdx.z * gridDim.y + blockIdx.y) * gridDim.x + blockIdx.x;
|
|
const auto thread_rank_in_block =
|
|
(threadIdx.z * blockDim.y + threadIdx.y) * blockDim.x + threadIdx.x;
|
|
return block_rank_in_grid * block_size + thread_rank_in_block;
|
|
}
|
|
|
|
template <class T> bool CheckDimensions(unsigned int device, T kernel, dim3 blocks, dim3 threads) {
|
|
hipDeviceProp_t props;
|
|
int max_blocks_per_sm = 0;
|
|
int num_sm = 0;
|
|
HIP_CHECK(hipSetDevice(device));
|
|
HIP_CHECK(hipOccupancyMaxActiveBlocksPerMultiprocessor(&max_blocks_per_sm, kernel,
|
|
threads.x * threads.y * threads.z, 0));
|
|
|
|
HIP_CHECK(hipGetDeviceProperties(&props, device));
|
|
num_sm = props.multiProcessorCount;
|
|
|
|
if ((blocks.x * blocks.y * blocks.z) >= max_blocks_per_sm * num_sm ||
|
|
blocks.x <= 0 || blocks.y <= 0 || blocks.z <= 0 ||
|
|
threads.x <= 0 || threads.y <= 0 || threads.z <= 0) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|