Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,21 @@
// RUN: %libomp-compile && env KMP_AFFINITY=disabled KMP_TOPOLOGY_METHOD=hwloc %libomp-run
// REQUIRES: hwloc
#include <stdio.h>
#include <stdlib.h>
// Test will assert() without fix
int test_affinity_disabled_plus_hwloc() {
#pragma omp parallel
{}
return 1;
}
int main(int argc, char **argv) {
int i, j;
int failed = 0;
if (!test_affinity_disabled_plus_hwloc()) {
failed = 1;
}
return failed;
}

View File

@@ -0,0 +1,76 @@
// RUN: %libomp-compile && env KMP_DISP_NUM_BUFFERS=0 %libomp-run
// RUN: env KMP_DISP_NUM_BUFFERS=1 %libomp-run && env KMP_DISP_NUM_BUFFERS=3 %libomp-run
// RUN: env KMP_DISP_NUM_BUFFERS=4 %libomp-run && env KMP_DISP_NUM_BUFFERS=7 %libomp-run
// RUN: %libomp-compile -DMY_SCHEDULE=guided && env KMP_DISP_NUM_BUFFERS=1 %libomp-run
// RUN: env KMP_DISP_NUM_BUFFERS=3 %libomp-run && env KMP_DISP_NUM_BUFFERS=4 %libomp-run
// RUN: env KMP_DISP_NUM_BUFFERS=7 %libomp-run
#include <stdio.h>
#include <omp.h>
#include <stdlib.h>
#include <limits.h>
#include "omp_testsuite.h"
#define INCR 7
#define MY_MAX 200
#define MY_MIN -200
#define NUM_LOOPS 100
#ifndef MY_SCHEDULE
# define MY_SCHEDULE dynamic
#endif
int a, b, a_known_value, b_known_value;
int test_kmp_set_disp_num_buffers()
{
int success = 1;
a = 0;
b = 0;
// run many small dynamic loops to stress the dispatch buffer system
#pragma omp parallel
{
int i,j;
for (j = 0; j < NUM_LOOPS; j++) {
#pragma omp for schedule(MY_SCHEDULE) nowait
for (i = MY_MIN; i < MY_MAX; i+=INCR) {
#pragma omp atomic
a++;
}
#pragma omp for schedule(MY_SCHEDULE) nowait
for (i = MY_MAX; i >= MY_MIN; i-=INCR) {
#pragma omp atomic
b++;
}
}
}
// detect failure
if (a != a_known_value || b != b_known_value) {
success = 0;
printf("a = %d (should be %d), b = %d (should be %d)\n", a, a_known_value,
b, b_known_value);
}
return success;
}
int main(int argc, char** argv)
{
int i,j;
int num_failed=0;
// figure out the known values to compare with calculated result
a_known_value = 0;
b_known_value = 0;
for (j = 0; j < NUM_LOOPS; j++) {
for (i = MY_MIN; i < MY_MAX; i+=INCR)
a_known_value++;
for (i = MY_MAX; i >= MY_MIN; i-=INCR)
b_known_value++;
}
for(i = 0; i < REPETITIONS; i++) {
if(!test_kmp_set_disp_num_buffers()) {
num_failed++;
}
}
return num_failed;
}

View File

@@ -0,0 +1,82 @@
// 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;
}
}

View File

@@ -0,0 +1,40 @@
// RUN: %libomp-compile && env OMP_WAIT_POLICY=active %libomp-run active
// RUN: %libomp-compile && env OMP_WAIT_POLICY=passive %libomp-run passive
//
// OMP_WAIT_POLICY=active should imply blocktime == INT_MAX
// i.e., threads spin-wait forever
// OMP_WAIT_POLICY=passive should imply blocktime == 0
// i.e., threads immediately sleep
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "omp_testsuite.h"
void usage() {
fprintf(stderr, "usage: omp_wait_policy active|passive\n");
}
int main(int argc, char** argv)
{
int blocktime, retval=1;
const char* env_var_value;
if (argc != 2) {
usage();
return 1;
}
blocktime = kmp_get_blocktime();
env_var_value = argv[1];
if (!strcmp(env_var_value, "active")) {
retval = (blocktime != INT_MAX);
} else if (!strcmp(env_var_value, "passive")) {
retval = (blocktime != 0);
} else {
usage();
retval = 1;
}
return retval;
}