24#define CFSMAX_SIZE 1000
29#define SLEEPTIME 0.0001
42 tids = (
int *) malloc (
sizeof (
int) * (
CFSMAX_SIZE + 1));
65 #pragma omp parallel shared(tids,maxiter)
71 tid = omp_get_thread_num ();
73 #pragma omp for nowait schedule(guided)
76 #pragma omp flush(maxiter)
84 #pragma omp flush(maxiter,notout)
86 #pragma omp flush(maxiter,notout)
94 if (
count > 0.) printf(
" waited %lf s\n",
count);
99 printf(
"%d finished by %d\n",
j,tid);
103 #pragma omp flush(maxiter,notout)
110 int determined_chunksize = 1;
111 int last_threadnr = tids[0];
112 int global_chunknr = 0;
114 int expected_chunk_size;
115 int* local_chunknr = (
int*)malloc(threads *
sizeof(
int));
118 for (
i = 0;
i < threads;
i++)
119 local_chunknr[
i] = 0;
128 if (last_threadnr==tids[
i]) {
129 determined_chunksize++;
134 local_chunknr[last_threadnr]++;
135 last_threadnr = tids[
i];
136 determined_chunksize = 1;
140 chunksizes = (
int*)malloc(global_chunknr *
sizeof(
int));
146 determined_chunksize = 1;
147 last_threadnr = tids[0];
154 if (last_threadnr == tids[
i]) {
155 determined_chunksize++;
157 chunksizes[global_chunknr] = determined_chunksize;
159 local_chunknr[last_threadnr]++;
160 last_threadnr = tids[
i];
161 determined_chunksize = 1;
166 fprintf(stderr,
"found\texpected\tconstant\n");
171 expected_chunk_size = openwork / threads;
172 c = (
double) chunksizes[0] / expected_chunk_size;
174 for (
i = 0;
i < global_chunknr;
i++) {
176 if (expected_chunk_size > 1)
177 expected_chunk_size = c * openwork / threads;
179 fprintf(stderr,
"%8d\t%8d\t%lf\n", chunksizes[
i],
180 expected_chunk_size, c * chunksizes[
i]/expected_chunk_size);
183 if (abs (chunksizes[
i] - expected_chunk_size) >= 2) {
186 fprintf(stderr,
"Chunksize differed from expected "
187 "value: %d instead of %d\n", chunksizes[
i],
188 expected_chunk_size);
194 if (expected_chunk_size - chunksizes[
i] < 0)
195 fprintf(stderr,
"Chunksize did not decrease: %d"
196 " instead of %d\n", chunksizes[
i],expected_chunk_size);
200 openwork -= chunksizes[
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
KMP_ARCH_X86 KMP_ARCH_X86 long double
#define omp_set_num_threads
int test_omp_for_schedule_guided()
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()