Summary: I have discovered this because i wanted to experiment with building static libomp (with openmp-4.0 support only) for debugging purposes. There are three kinds of problems here: 1. `__kmp_compare_and_store_acq()` simply does not exist. It was added in D47903 by @jlpeyton. I'm guessing `__kmp_atomic_compare_store_acq()` was meant. 2. In `__kmp_is_ticket_lock_initialized()`, `lck->lk.initialized` is `std::atomic<bool>`, while `lck` is `kmp_ticket_lock_t *`. Naturally, they can't be equality-compared. Either, it should return the value read from `lck->lk.initialized`, or do what `__kmp_is_queuing_lock_initialized()` does, compare the passed pointer with the field in the struct pointed by the pointer. I think the latter is correct-er choice here. 3. Tests were not versioned. They assume that `LIBOMP_OMP_VERSION` is at the latest version. This does not touch LIBOMP_OMP_VERSION=30. That is still broken. Reviewers: jlpeyton, Hahnfeld, AndreyChurbanov Reviewed By: AndreyChurbanov Subscribers: guansong, jfb, openmp-commits, jlpeyton Tags: #openmp Differential Revision: https://reviews.llvm.org/D55496 llvm-svn: 349260
73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
// RUN: %libomp-compile-and-run
|
|
// RUN: %libomp-compile && env KMP_TASKLOOP_MIN_TASKS=1 %libomp-run
|
|
// REQUIRES: openmp-4.5
|
|
|
|
// These compilers don't support the taskloop construct
|
|
// UNSUPPORTED: gcc-4, gcc-5, icc-16
|
|
|
|
/*
|
|
* Test for taskloop
|
|
* Method: caculate how many times the iteration space is dispatched
|
|
* and judge if each dispatch has the requested grainsize
|
|
* It is possible for two adjacent chunks are executed by the same thread
|
|
*/
|
|
#include <stdio.h>
|
|
#include <omp.h>
|
|
#include <stdlib.h>
|
|
#include "omp_testsuite.h"
|
|
|
|
#define CFDMAX_SIZE 1120
|
|
|
|
int test_omp_taskloop_num_tasks()
|
|
{
|
|
int i;
|
|
int *tids;
|
|
int *tidsArray;
|
|
int count;
|
|
int result = 0;
|
|
int num_tasks;
|
|
|
|
for (num_tasks = 1; num_tasks < 120; ++num_tasks) {
|
|
count = 0;
|
|
tidsArray = (int *)malloc(sizeof(int) * CFDMAX_SIZE);
|
|
tids = tidsArray;
|
|
|
|
#pragma omp parallel shared(tids)
|
|
{
|
|
int i;
|
|
#pragma omp master
|
|
#pragma omp taskloop num_tasks(num_tasks)
|
|
for (i = 0; i < CFDMAX_SIZE; i++) {
|
|
tids[i] = omp_get_thread_num();
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < CFDMAX_SIZE - 1; ++i) {
|
|
if (tids[i] != tids[i + 1]) {
|
|
count++;
|
|
}
|
|
}
|
|
|
|
if (count > num_tasks) {
|
|
fprintf(stderr, "counted too many tasks: (wanted %d, got %d)\n",
|
|
num_tasks, count);
|
|
result++;
|
|
}
|
|
}
|
|
|
|
return (result==0);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int i;
|
|
int num_failed=0;
|
|
|
|
for (i = 0; i < REPETITIONS; i++) {
|
|
if (!test_omp_taskloop_num_tasks()) {
|
|
num_failed++;
|
|
}
|
|
}
|
|
return num_failed;
|
|
}
|