24
edits
Changes
→Walkthrough
= Walkthrough =
=== Environment === ==== IDE ==== * Microsoft Visual Studio 2019 ==== Compiler ==== * Intel oneAPI DPC++/C++ === Sample Code === <syntaxhighlight lang="cpp">#include <stdio.h>#include <omp.h> int main(int argc, char** argv) { int partial_Sum, total_Sum; #pragma omp parallel private(partial_Sum) shared(total_Sum) { partial_Sum = 0; total_Sum = 0; #pragma omp for { for (int i = 1; i <= 1000; i++) { partial_Sum += i; } } //Create thread safe region.#pragma omp critical { //add each threads partial sum to the total sum total_Sum += partial_Sum; } } printf("Total Sum : % d\n", total_Sum); return 0;}</ use same syntaxhighlight> === Configuration === Enable OpenMP for the current project file '''Project''' - '''Property''' - '''C/C++''' - '''Language [Intel C++]''' - '''OpenMP Support''' - '''Generate Parallel Code (/Qiopenmp)''' [[File: config.png]] === Output === * The output of the sample program for both tests
== Case A: Using the Thread Window ==