Intel® C++ Compiler 16.0 User and Reference Guide

omp parallel for

Specifies a parallel construct containing one or more associated loops.

Syntax

#pragma omp parallel for [clause, clause, ...]

for-loop

Arguments

clause

Any clause accepted by the for or parallel constructs.

Description

This pragma is a shortcut for a parallel construct that contains a single for pragma.

Example: Multiplying two matrices by parallelizing the outer loop

#include <omp.h>
#pragma omp parallel for private(i,j,k)
for (i=0; i<N; i++) {
		for (j=0; j<N; j++) {
		 	for (k=0; k<N; k++) {
				  a[i,k] = a[i,k] + b[i,j] * c[j,k];
	 		}
 	}
}