Skip to content

Latest commit

 

History

History
78 lines (69 loc) · 2.43 KB

private_clause.md

File metadata and controls

78 lines (69 loc) · 2.43 KB
layout title release_number author tutorial
tutorial_page
OpenMP Directives: Data Scope Attribute Clauses: PRIVATE Clause
UCRL-MI-133316
Blaise Barney, Lawrence Livermore National Laboratory
OpenMP

Purpose:

The PRIVATE clause declares variables in its list to be private to each thread.

Format:

Fortran

PRIVATE (list)

C/C++

private (list)

Notes:

  • PRIVATE variables behave as follows:

    • A new object of the same type is declared once for each thread in the team
    • All references to the original object are replaced with references to the new object
    • Variables declared PRIVATE should be assumed to be uninitialized for each thread
  • Comparison between PRIVATE and THREADPRIVATE:

<style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-xq0d{background-color:#98ABCE;font-weight:bold;text-align:center;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style>
PRIVATE THREADPRIVATE
Data Item C/C++: variable
Fortran: variable or common block
C/C++: variable
Fortran: common block
Where Declared At start of region or work-sharing group In declarations of each routine using block or global file scope
Persistent? No Yes
Extent Lexical only - unless passed as an argument to subroutine Dynamic
Initialized Use FIRSTPRIVATE Use COPYIN