다음을 통해 공유


C. OpenMP C 및 C++ 문법

C.1 표기법
C.2 규칙

C.1 표기법

문법 규칙은 비종결어의 이름과 콜론, 그리고 별도의 줄에 대체어를 나열하는 것으로 구성됩니다.

구문 표현식 용어opt는 대체 용어 내에서 선택 사항임을 나타냅니다.

구문 식 termoptseq는 다음 추가 규칙에 의해 term-seqopt와 동등합니다.

term-seq:
term
term-seq term
term-seq , term

C.2 규칙

표기법은 C 표준의 섹션 6.1에 설명되어 있습니다. 이 문법 부록은 OpenMP C 및 C++ 지시어에 대한 기본 언어 문법의 확장을 보여줍니다.

/* C++ (ISO/IEC 14882:1998) 내 */

statement-seq:
statement
openmp-directive
statement-seq statement
statement-seq openmp-directive

/* C90 (ISO/IEC 9899:1990) 내 */

statement-list:
statement
openmp-directive
statement-list statement
statement-list openmp-directive

/* C99 (ISO/IEC 9899:1999) 내 */

block-item:
declaration
statement
openmp-directive

/* 표준 문 */

statement:
openmp-construct

openmp-construct:
parallel-construct
for-construct
sections-construct
single-construct
parallel-for-construct
parallel-sections-construct
master-construct
critical-construct
atomic-construct
ordered-construct

openmp-directive:
barrier-directive
flush-directive

structured-block:
statement

parallel-construct:
parallel-directive structured-block

parallel-directive:
# pragma omp parallel parallel-clauseoptseq new-line

parallel-clause:
unique-parallel-clause
data-clause

unique-parallel-clause:
if ( expression )
num_threads ( expression )

for-construct:
for-directive iteration-statement

for-directive:
# pragma omp for for-clauseoptseq new-line

for-clause:
unique-for-clause
data-clause
nowait

unique-for-clause:
ordered
schedule ( schedule-kind )
schedule ( schedule-kind , expression )

schedule-kind:
static
dynamic
guided
runtime

sections-construct:
sections-directive section-scope

sections-directive:
# pragma omp sections sections-clauseoptseq new-line

sections-clause:
data-clause
nowait

section-scope:
{ section-sequence }

section-sequence:
section-directiveopt structured-block
section-sequence section-directive structured-block

section-directive:
# pragma omp section new-line

single-construct:
single-directive structured-block

single-directive:
# pragma omp single single-clauseoptseq new-line

single-clause:
data-clause
nowait

parallel-for-construct:
parallel-for-directive iteration-statement

parallel-for-directive:
# pragma omp parallel for parallel-for-clauseoptseq new-line

parallel-for-clause:
unique-parallel-clause
unique-for-clause
data-clause

parallel-sections-construct:
parallel-sections-directive section-scope

parallel-sections-directive:
# pragma omp parallel sections parallel-sections-clauseoptseq new-line

parallel-sections-clause:
unique-parallel-clause
data-clause

master-construct:
master-directive structured-block

master-directive:
# pragma omp master new-line

critical-construct:
critical-directive structured-block

critical-directive:
# pragma omp critical region-phraseopt new-line

region-phrase:
(identifier)

barrier-directive:
# pragma omp barrier new-line

atomic-construct:
atomic-directive expression-statement

atomic-directive:
# pragma omp atomic new-line

flush-directive:
# pragma omp flush flush-varsopt new-line

flush-vars:
(variable-list)

ordered-construct:
ordered-directive structured-block

ordered-directive:
# pragma omp ordered new-line

/* 표준 선언 */

declaration:
threadprivate-directive

threadprivate-directive:
# pragma omp threadprivate ( variable-list ) new-line

data-clause:
private ( variable-list )
copyprivate ( variable-list )
firstprivate ( variable-list )
lastprivate ( variable-list )
shared ( variable-list )
default ( shared )
default ( none )
reduction ( reduction-operator : variable-list )
copyin ( variable-list )

reduction-operator:
 다음 중 하나: + \* - & ^ | && ||

/* C 내 */

variable-list:
identifier
variable-list , identifier

/* C++ 내 */

variable-list:
id-expression
variable-list , id-expression