Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame^] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp task directive. The idea of the tests is to generate a set of tasks in a single region. We let pause the tasks generated so that other threads get sheduled to the newly opened tasks.</ompts:testdescription> |
| 3 | <ompts:ompversion>3.0</ompts:ompversion> |
| 4 | <ompts:directive>omp task final</ompts:directive> |
| 5 | <ompts:dependences>omp single</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | #include <stdio.h> |
| 8 | #include <math.h> |
| 9 | #include "omp_testsuite.h" |
| 10 | #include "omp_my_sleep.h" |
| 11 | |
| 12 | |
| 13 | int <ompts:testcode:functionname>omp_task_final</ompts:testcode:functionname>(FILE * logFile){ |
| 14 | <ompts:orphan:vars> |
| 15 | int tids[NUM_TASKS]; |
| 16 | int i; |
| 17 | </ompts:orphan:vars> |
| 18 | int error; |
| 19 | #pragma omp parallel |
| 20 | { |
| 21 | #pragma omp single |
| 22 | { |
| 23 | for (i = 0; i < NUM_TASKS; i++) { |
| 24 | <ompts:orphan> |
| 25 | /* First we have to store the value of the loop index in a new variable |
| 26 | * which will be private for each task because otherwise it will be overwritten |
| 27 | * if the execution of the task takes longer than the time which is needed to |
| 28 | * enter the next step of the loop! |
| 29 | */ |
| 30 | int myi; |
| 31 | myi = i; |
| 32 | |
| 33 | #pragma omp task <ompts:check>final(i>=10)</ompts:check> |
| 34 | { |
| 35 | my_sleep (SLEEPTIME); |
| 36 | |
| 37 | tids[myi] = omp_get_thread_num(); |
| 38 | } /* end of omp task */ |
| 39 | </ompts:orphan> |
| 40 | } /* end of for */ |
| 41 | } /* end of single */ |
| 42 | } /*end of parallel */ |
| 43 | |
| 44 | /* Now we ckeck if more than one thread executed the tasks. */ |
| 45 | for (i = 10; i < NUM_TASKS; i++) { |
| 46 | if (tids[10] != tids[i]) |
| 47 | error++; |
| 48 | } |
| 49 | return (error==0); |
| 50 | } /* end of check_paralel_for_private */ |
| 51 | </ompts:testcode> |
| 52 | </ompts:test> |