icp/oer/courses/c-openmp/sections/02-advanced/07-tasks/content.md

10 lines
439 B
Markdown
Raw Normal View History

2018-05-05 22:18:02 +00:00
Task offer an easy way to offload a block of code to another thread, while the main thread can keep going.
## Knowledge
To mark a block of code as a task, use the ``pragma omp task`` directive. The current thread will keep going, while another thread will execute the specified block.
If you need to be sure that all the task are done before you proceed use the ``pragma omp taskwait`` directive.
## Task
Use task to speed up the code.