Skip to content

Latest commit

 

History

History
46 lines (45 loc) · 1.03 KB

a-4-using-the-nowait-clause.md

File metadata and controls

46 lines (45 loc) · 1.03 KB
title A.4 Using the nowait Clause | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic article
dev_langs
C++
ms.assetid d3de2111-05ea-4ee3-a66c-57bd988712af
caps.latest.revision 8
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

A.4 Using the nowait Clause

If there are multiple independent loops within a parallel region, you can use the nowait clause (Section 2.4.1 on page 11) to avoid the implied barrier at the end of the for directive, as follows:

#pragma omp parallel  
{  
    #pragma omp for nowait  
        for (i=1; i<n; i++)  
             b[i] = (a[i] + a[i-1]) / 2.0;  
    #pragma omp for nowait  
        for (i=0; i<m; i++)  
            y[i] = sqrt(z[i]);  
}