°C OpenMP C 和 C++ 语法
C.1 表示法
语法规则包括非终端的名称,后跟冒号,后跟单独的行上的替换替代项。
语法表达式术语 opt 指示该术语在替换中是可选的。
语法表达式术语optseq 等于带有以下附加规则的 term-seqopt:
term-seq:
term
term-seq term
term-seq ,
term
C.2 规则
C 标准的第 6.1 节介绍了表示法。 此语法附录介绍了 OpenMP C 和 C++ 指令的基本语言语法的扩展。
/* in C++ (ISO/IEC 14882:1998) */
statement-seq:
语句
openmp-directive
statement-seq 语句
statement-seq openmp-directive
/* in C90 (ISO/IEC 9899:1990) */
statement-list:
语句
openmp-directive
statement-list statement
statement-list openmp-directive
/* in C99 (ISO/IEC 9899:1999) */
block-item:
declaration
语句
openmp-directive
/* standard statements */
语句:
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:
语句
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
/* standard declarations */
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:
以下项之一:+ \* - & ^ | && ||
/* in C */
variable-list:
identifier
variable-list ,
identifier
/* in C++ */
variable-list:
id-expression
variable-list ,
id-expression