Tutorial by Examples

This example illustrates the basics of executing sections of code in parallel. As OpenMP is a built-in compiler feature, it works on any supported compilers without including any libraries. You may wish to include omp.h if you want to use any of the openMP API features. Sample Code std::cout <...
This example shows how to execute chunks of code in parallel std::cout << "begin "; // Start of parallel sections #pragma omp parallel sections { // Execute these sections in parallel #pragma omp section { ... do something ... std::cout <...
This example shows how to divide a loop into equal parts and execute them in parallel. // Splits element vector into element.size() / Thread Qty // and allocate that range for each thread. #pragma omp parallel for for (size_t i = 0; i < element.size(); ++i) element[i] = ... /...
This example illustrates a concept to perform reduction or gathering using std::vector and OpenMP. Supposed we have a scenario where we want multiple threads to help us generate a bunch of stuff, int is used here for simplicity and can be replaced with other data types. This is particularly useful...

Page 1 of 1