5 #include <unistd.h> // For 'alarm'.
7 #include "on_device_arch.h"
9 /* Test tasks with detach clause on an offload device. Each device
10 thread spawns off a chain of tasks, that can then be executed by
11 any available thread. */
15 //TODO See '../libgomp.c/pr99555-1.c'.
16 if (on_device_arch_nvptx ())
17 alarm (4); /*TODO Until resolved, make sure that we exit quickly, with error status.
18 { dg-xfail-run-if "PR99555" { offload_device_nvptx } } */
20 int x
= 0, y
= 0, z
= 0;
22 omp_event_handle_t detach_event1
, detach_event2
;
24 #pragma omp target map (tofrom: x, y, z) map (from: thread_count)
25 #pragma omp parallel private (detach_event1, detach_event2)
28 thread_count
= omp_get_num_threads ();
30 #pragma omp task detach(detach_event1) untied
31 #pragma omp atomic update
34 #pragma omp task detach(detach_event2) untied
36 #pragma omp atomic update
38 omp_fulfill_event (detach_event1
);
41 #pragma omp task untied
43 #pragma omp atomic update
45 omp_fulfill_event (detach_event2
);
49 assert (x
== thread_count
);
50 assert (y
== thread_count
);
51 assert (z
== thread_count
);