blob: ae89790cd84c8d30c8bc220fe5f57d14c7461e6f [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<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</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
13int <ompts:testcode:functionname>omp_task</ompts:testcode:functionname>(FILE * logFile){
14 <ompts:orphan:vars>
15 int tids[NUM_TASKS];
16 int i;
17 </ompts:orphan:vars>
18
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<ompts:check>#pragma omp task</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 = 1; i < NUM_TASKS; i++) {
46 if (tids[0] != tids[i])
47 return 1;
48 }
49 return 0;
Alp Tokerc2d5e612014-06-01 18:28:36 +000050} /* end of check_parallel_for_private */
Jim Cownie18d84732014-05-10 17:02:09 +000051</ompts:testcode>
52</ompts:test>