kupl_in_parallel
Check whether the current thread is in the parallel domain.
Interface Definition
bool kupl_in_parallel();
Return Value
- true: in the parallel domain
- false: not in the parallel domain
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> #include <assert.h> #include "kupl.h" static void task_int_parallel(kupl_nd_range_t *nd_range, void *args, int tid, int tnum) { bool in_parallel = kupl_in_parallel(); assert(in_parallel == true); } int main() { kupl_parallel_for_desc_t desc = { .field_mask = KUPL_PARALLEL_FOR_DESC_FIELD_DEFAULT, .range = nullptr, .egroup = nullptr, .concurrency = 4, .policy = KUPL_LOOP_POLICY_STATIC }; kupl_parallel_for(&desc, task_int_parallel, nullptr); } |
- The preceding example demonstrates the process of enabling the parallel domain and checking whether the current thread is in the parallel domain.
- The kupl_in_parallel function is called within the parallel domain, so true is returned.
Parent topic: Multi-threaded Programming Functions