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,23 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include <stdlib.h>
#include "omp_testsuite.h"
int test_has_openmp()
{
int rvalue = 0;
#ifdef _OPENMP
rvalue = 1;
#endif
return (rvalue);
}
int main()
{
int i;
int num_failed=0;
if(!test_has_openmp()) {
num_failed++;
}
return num_failed;
}

View File

@@ -0,0 +1,62 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include <stdint.h>
#include <omp.h>
#include "omp_testsuite.h"
int alignments[] = {64, 128, 256, 512, 1024, 2048, 4096};
unsigned aligned_by(uint64_t addr) {
uint64_t alignment = 1;
while((addr & (alignment-1)) == 0) {
alignment <<= 1;
}
return (alignment >> 1);
}
int test_kmp_aligned_malloc()
{
int err = 0;
#pragma omp parallel shared(err)
{
int i;
int* ptr;
uint64_t addr;
int tid = omp_get_thread_num();
for(i = 0; i < sizeof(alignments)/sizeof(int); i++) {
int alignment = alignments[i];
// allocate 64 bytes with 64-byte alignment
// allocate 128 bytes with 128-byte alignment, etc.
ptr = (int*)kmp_aligned_malloc(alignment, alignment);
addr = (uint64_t)ptr;
if(addr & (alignment-1)) {
printf("thread %d: addr = %p (aligned to %u bytes) but expected "
" alignment = %d\n", tid, ptr, aligned_by(addr), alignment);
err = 1;
}
kmp_free(ptr);
}
ptr = kmp_aligned_malloc(128, 127);
if (ptr != NULL) {
printf("thread %d: kmp_aligned_malloc() didn't return NULL when "
"alignment was not power of 2\n", tid);
err = 1;
}
} /* end of parallel */
return !err;
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_kmp_aligned_malloc()) {
num_failed++;
}
}
return num_failed;
}

View File

@@ -0,0 +1,53 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include "omp_testsuite.h"
/* The bug occurs if the lock table is reallocated after
kmp_set_defaults() is called. If the table is reallocated,
then the lock will not point to a valid lock object after the
kmp_set_defaults() call.*/
omp_lock_t lock;
int test_kmp_set_defaults_lock_bug()
{
/* checks that omp_get_num_threads is equal to the number of
threads */
int nthreads_lib;
int nthreads = 0;
nthreads_lib = -1;
#pragma omp parallel
{
omp_set_lock(&lock);
nthreads++;
omp_unset_lock(&lock);
#pragma omp single
{
nthreads_lib = omp_get_num_threads ();
} /* end of single */
} /* end of parallel */
kmp_set_defaults("OMP_NUM_THREADS");
#pragma omp parallel
{
omp_set_lock(&lock);
nthreads++;
omp_unset_lock(&lock);
} /* end of parallel */
return (nthreads == 2*nthreads_lib);
}
int main()
{
int i;
int num_failed=0;
omp_init_lock(&lock);
for(i = 0; i < REPETITIONS; i++) {
if(!test_kmp_set_defaults_lock_bug()) {
num_failed++;
}
}
omp_destroy_lock(&lock);
return num_failed;
}

View File

@@ -0,0 +1,39 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include "omp_testsuite.h"
int test_omp_get_num_threads()
{
/* checks that omp_get_num_threads is equal to the number of
threads */
int nthreads_lib;
int nthreads = 0;
nthreads_lib = -1;
#pragma omp parallel
{
#pragma omp critical
{
nthreads++;
} /* end of critical */
#pragma omp single
{
nthreads_lib = omp_get_num_threads ();
} /* end of single */
} /* end of parallel */
return (nthreads == nthreads_lib);
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_get_num_threads()) {
num_failed++;
}
}
return num_failed;
}

View File

@@ -0,0 +1,24 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include "omp_testsuite.h"
int test_omp_get_wtick()
{
double tick;
tick = -1.;
tick = omp_get_wtick ();
return ((tick > 0.0) && (tick < 0.01));
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_get_wtick()) {
num_failed++;
}
}
return num_failed;
}

View File

@@ -0,0 +1,33 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include <stdlib.h>
#include "omp_testsuite.h"
#include "omp_my_sleep.h"
int test_omp_get_wtime()
{
double start;
double end;
double measured_time;
double wait_time = 5.0;
start = 0;
end = 0;
start = omp_get_wtime();
my_sleep (wait_time);
end = omp_get_wtime();
measured_time = end-start;
return ((measured_time > 0.97 * wait_time) && (measured_time < 1.03 * wait_time)) ;
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_get_wtime()) {
num_failed++;
}
}
return num_failed;
}

View File

@@ -0,0 +1,39 @@
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include "omp_testsuite.h"
/*
* Checks that false is returned when called from serial region
* and true is returned when called within parallel region.
*/
int test_omp_in_parallel()
{
int serial;
int isparallel;
serial = 1;
isparallel = 0;
serial = omp_in_parallel();
#pragma omp parallel
{
#pragma omp single
{
isparallel = omp_in_parallel();
}
}
return (!(serial) && isparallel);
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_in_parallel()) {
num_failed++;
}
}
return num_failed;
}