<commit_before>\sekshun{Task Parallelism and Synchronization}
\label{Task_Parallelism_and_Synchronization}
\index{synchronization}

Chapel supports both task parallelism and data parallelism.  This
chapter details task parallelism as follows:
\begin{itemize}
\item \rsec{Task_parallelism} introduces tasks and task parallelism.
\item \rsec{Begin} describes the begin statement, an unstructured way
to introduce concurrency into a program.
\item \rsec{Synchronization_Variables} describes synchronization
variables, an unstructured mechanism for synchronizing tasks.
\item \rsec{Cobegin} describes the cobegin statement, a structured way to
introduce concurrency into a program.
\item \rsec{Coforall} describes the coforall loop, another structured way to
introduce concurrency into a program.
\item \rsec{Sync_Statement} describes the sync statement, a structured
way to control parallelism.
\item \rsec{Serial} describes the serial statement, a structured way to suppress
parallelism.
\item \rsec{Atomic_Statement} describes the atomic statement, a construct to
support atomic transactions.
\end{itemize}

\section{Tasks and Task Parallelism}
\label{Task_parallelism}
\index{task parallelism}
\index{parallelism!task}

A Chapel \emph{task} is a distinct context of execution that maybe
running concurrently with other tasks.  Chapel provides a simple
construct, the begin statement, to create tasks, introducing
concurrency into a program in an unstructured way.  In addition,
Chapel introduces two type qualifiers, \chpl{sync} and \chpl{single},
for synchronization between tasks.

Chapel provides two constructs, the cobegin and coforall statements,
to introduce concurrency in a more structured way.  These constructs
create multiple tasks but do not continue until the tasks have
completed.  In addition, Chapel provides two constructs, the sync- and
serial statements, to suppress parallelism and insert synchronization.
All four of these constructs can be implemented through judicious uses
of the unstructured task-parallel constructs described in the previous
section.


\section{The Begin Statement}
\label{Begin}
\index{begin@\chpl{begin}}
\index{statements!begin}

The begin statement creates a task to execute a statement.  The syntax
for the begin statement is given by
\begin{syntax}
begin-statement:<commit_msg>Minor tweak to the spec. [trivial]<commit_after>\sekshun{Task Parallelism and Synchronization}
\label{Task_Parallelism_and_Synchronization}
\index{synchronization}

Chapel supports both task parallelism and data parallelism.  This
chapter details task parallelism as follows:
\begin{itemize}
\item \rsec{Task_parallelism} introduces tasks and task parallelism.
\item \rsec{Begin} describes the begin statement, an unstructured way
to introduce concurrency into a program.
\item \rsec{Synchronization_Variables} describes synchronization
variables, an unstructured mechanism for synchronizing tasks.
\item \rsec{Cobegin} describes the cobegin statement, a structured way to
introduce concurrency into a program.
\item \rsec{Coforall} describes the coforall loop, another structured way to
introduce concurrency into a program.
\item \rsec{Sync_Statement} describes the sync statement, a structured
way to control parallelism.
\item \rsec{Serial} describes the serial statement, a structured way to suppress
parallelism.
\item \rsec{Atomic_Statement} describes the atomic statement, a construct to
support atomic transactions.
\end{itemize}

\section{Tasks and Task Parallelism}
\label{Task_parallelism}
\index{task parallelism}
\index{parallelism!task}

A Chapel \emph{task} is a distinct context of execution that maybe
running concurrently with other tasks.  Chapel provides a simple
construct, the begin statement, to create tasks, introducing
concurrency into a program in an unstructured way.  In addition,
Chapel introduces two type qualifiers, \chpl{sync} and \chpl{single},
for synchronization between tasks.

Chapel provides two constructs, the cobegin and coforall statements,
to introduce concurrency in a more structured way.  These constructs
create multiple tasks but do not continue until the tasks have
completed.  In addition, Chapel provides two constructs, the \chpl{sync} and
\chpl{serial} statements, to insert synchronization and suppress parallelism.
All four of these constructs can be implemented through judicious uses
of the unstructured task-parallel constructs described in the previous
section.


\section{The Begin Statement}
\label{Begin}
\index{begin@\chpl{begin}}
\index{statements!begin}

The begin statement creates a task to execute a statement.  The syntax
for the begin statement is given by
\begin{syntax}
begin-statement:
{'fraction_non_alphanumeric': 0.05802047781569966, 'fraction_numerical': 0.0, 'mean_word_length': 5.776011560693641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4323690', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1187, 'n_words': 556}