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
67 lines
2.0 KiB
C
67 lines
2.0 KiB
C
// RUN: %libomp-compile -D_GNU_SOURCE
|
|
// RUN: env OMP_NUM_THREADS=2,2 KMP_AFFINITY=reset,granularity=thread,compact %libomp-run
|
|
// REQUIRES: linux
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <omp.h>
|
|
#include "libomp_test_affinity.h"
|
|
|
|
#define CHECK_EQUAL 0
|
|
#define CHECK_NOT_EQUAL 1
|
|
|
|
void check_primary_thread_affinity(int line, affinity_mask_t *other_aff,
|
|
int type) {
|
|
#pragma omp master
|
|
{
|
|
affinity_mask_t *primary_aff = affinity_mask_alloc();
|
|
get_thread_affinity(primary_aff);
|
|
if (type == CHECK_EQUAL && !affinity_mask_equal(primary_aff, other_aff)) {
|
|
fprintf(stderr, "error: line %d: primary affinity was not equal\n", line);
|
|
exit(EXIT_FAILURE);
|
|
} else if (type == CHECK_NOT_EQUAL &&
|
|
affinity_mask_equal(primary_aff, other_aff)) {
|
|
fprintf(stderr, "error: line %d: primary affinity was equal\n", line);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
affinity_mask_free(primary_aff);
|
|
}
|
|
}
|
|
|
|
#define CHECK_PRIMARY_THREAD_AFFINITY_EQUAL(other_aff) \
|
|
check_primary_thread_affinity(__LINE__, other_aff, CHECK_EQUAL)
|
|
#define CHECK_PRIMARY_THREAD_AFFINITY_NOT_EQUAL(other_aff) \
|
|
check_primary_thread_affinity(__LINE__, other_aff, CHECK_NOT_EQUAL)
|
|
|
|
int main() {
|
|
int i;
|
|
affinity_mask_t *initial_mask = affinity_mask_alloc();
|
|
get_thread_affinity(initial_mask);
|
|
|
|
for (i = 0; i < 10; ++i) {
|
|
#pragma omp parallel
|
|
{
|
|
CHECK_PRIMARY_THREAD_AFFINITY_NOT_EQUAL(initial_mask);
|
|
}
|
|
CHECK_PRIMARY_THREAD_AFFINITY_EQUAL(initial_mask);
|
|
}
|
|
|
|
omp_set_max_active_levels(2);
|
|
for (i = 0; i < 10; ++i) {
|
|
#pragma omp parallel
|
|
{
|
|
CHECK_PRIMARY_THREAD_AFFINITY_NOT_EQUAL(initial_mask);
|
|
|
|
#pragma omp parallel
|
|
CHECK_PRIMARY_THREAD_AFFINITY_NOT_EQUAL(initial_mask);
|
|
|
|
CHECK_PRIMARY_THREAD_AFFINITY_NOT_EQUAL(initial_mask);
|
|
}
|
|
CHECK_PRIMARY_THREAD_AFFINITY_EQUAL(initial_mask);
|
|
}
|
|
|
|
affinity_mask_free(initial_mask);
|
|
return EXIT_SUCCESS;
|
|
}
|