7#define CFSMAX_SIZE 1000
12#define SLEEPTIME 0.0005
30 int lastthreadsstarttid = -1;
34 tids = (
int *) malloc (
sizeof (
int) * (
CFSMAX_SIZE + 1));
38 #pragma omp parallel shared(tids,counter)
51 fprintf (stderr,
"Using an internal count of %d\nUsing a"
55 #pragma omp parallel shared(tids)
61 tid = omp_get_thread_num ();
63 #pragma omp for nowait schedule(static,chunk_size)
66 #pragma omp flush(maxiter)
75 #pragma omp flush(maxiter,notout)
81 if (
count > 0.) printf(
" waited %lf s\n",
count);
86 printf(
"%d finished by %d\n",
j,tid);
91 #pragma omp flush(maxiter,notout)
102 if (tids[
i] == lasttid) {
105 fprintf (stderr,
"%d: %d \n",
i, tids[
i]);
113 if (tids[
i] == (lasttid + 1) % threads || tids[
i] == -1) {
119 fprintf (stderr,
"OK\n");
125 fprintf (stderr,
"Last thread had chunk size %d\n",
129 fprintf (stderr,
"ERROR: Last thread (thread with"
130 " number -1) was found before the end.\n");
134 fprintf (stderr,
"ERROR: chunk size was %d. (assigned"
140 fprintf(stderr,
"ERROR: Found thread with number %d (should be"
141 " inbetween 0 and %d).", tids[
i], threads - 1);
145 fprintf (stderr,
"%d: %d \n",
i, tids[
i]);
155 tids = (
int *) malloc (
sizeof (
int) *
LOOPCOUNT);
156 tids2 = (
int *) malloc (
sizeof (
int) *
LOOPCOUNT);
162 #pragma omp for schedule(static) nowait
167 tids[n] = omp_get_thread_num();
172 #pragma omp for schedule(static) nowait
174 tids2[m-1] = omp_get_thread_num();
180 if (tids[
i] != tids2[
i]) {
181 fprintf (stderr,
"Chunk no. %d was assigned once to thread %d and"
182 " later to thread %d.\n",
i, tids[
i],tids2[
i]);
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t count
#define omp_set_num_threads
int test_omp_for_schedule_static_3()
static void my_sleep(double sleeptime)
Utility function to have a sleep function with better resolution and which only stops one thread.
int omp_get_num_threads()