Files
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

83 lines
2.0 KiB
C

// RUN: %libomp-compile && env OMP_THREAD_LIMIT=4 %libomp-run 4
// RUN: %libomp-compile && env OMP_THREAD_LIMIT=7 %libomp-run 7
//
// OMP_THREAD_LIMIT=N should imply that no more than N threads are active in
// a contention group
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "omp_testsuite.h"
int failed = 0;
void usage() {
fprintf(stderr, "usage: omp_thread_limit <n>\n");
}
void verify(const char* file_name, int line_number, int team_size) {
int num_threads = omp_get_num_threads();
if (team_size != num_threads) {
#pragma omp critical(A)
{
char label[256];
snprintf(label, sizeof(label), "%s:%d", file_name, line_number);
failed = 1;
printf("failed: %s: team_size(%d) != omp_get_num_threads(%d)\n",
label, team_size, num_threads);
}
}
}
int main(int argc, char** argv)
{
int cl_thread_limit;
if (argc != 2) {
usage();
return 1;
}
cl_thread_limit = atoi(argv[1]);
omp_set_dynamic(0);
if (omp_get_thread_limit() != cl_thread_limit) {
fprintf(stderr, "omp_get_thread_limit failed with %d, should be%d\n",
omp_get_thread_limit(), cl_thread_limit);
return 1;
}
else if (omp_get_max_threads() > cl_thread_limit) {
#if _OPENMP
int team_size = cl_thread_limit;
#else
int team_size = 1;
#endif
omp_set_num_threads(19);
verify(__FILE__, __LINE__, 1);
#pragma omp parallel
{
verify(__FILE__, __LINE__, team_size);
verify(__FILE__, __LINE__, team_size);
}
verify(__FILE__, __LINE__, 1);
omp_set_nested(1);
#pragma omp parallel num_threads(3)
{
verify(__FILE__, __LINE__, 3);
#pragma omp master
#pragma omp parallel num_threads(21)
{
verify(__FILE__, __LINE__, team_size-2);
verify(__FILE__, __LINE__, team_size-2);
}
}
verify(__FILE__, __LINE__, 1);
return failed;
} else {
fprintf(stderr, "This test is not applicable for max num_threads='%d'\n",
omp_get_max_threads());
return 0;
}
}