Jonathan Peyton 96696b882b [OpenMP][libomp] Fix disabled affinity
Fix setting affinity type and topology method when affinity is disabled
and fix places that were not taking into account that affinity can be
explicitly disabled by putting proper KMP_AFFINITY_CAPABLE() check.

Differential Revision: https://reviews.llvm.org/D137176
2022-11-02 15:37:41 -05:00

26 lines
598 B
C

// RUN: %libomp-compile
// RUN: env KMP_AFFINITY=disabled %libomp-run
// RUN: env KMP_AFFINITY=disabled,reset %libomp-run
// REQUIRES: affinity
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
int main() {
int nthreads, correct_value;;
int a = 0;
#pragma omp parallel reduction(+: a)
{
a += omp_get_thread_num();
#pragma omp single
nthreads = omp_get_num_threads();
}
correct_value = nthreads * (nthreads - 1) / 2;
if (a != correct_value) {
printf("Incorrect value: %d should be %d\n", a, correct_value);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}