I was going through the specification of Chapel and was reading on Task Level Parallelism, in particular the synchronization variables (sync and single) and the logical state of them and how they go about. I came across this example given in the specification on this Link
var count$: sync int=0;
cobegin{
count$+=1
count$+=1
count$+=1
}
On running the above code, I get an error but the specification does not talk about it and expects the program to run properly. Why do I get this behaviour?
Chapel is a language that uses semicolons to terminate statements in order to avoid ambiguities. It looks to me like you dropped the semicolons from the three statements within the
cobegin
when transcribing the example from the language specification and that it should work once they are restored (TIO):Note that most of the examples in the language specification are available within the Chapel release in the
$CHPL_HOME/examples/spec/
directory, organized by chapter so that they need not be re-typed or cut-and-pasted. For example, that example (whose name is indicated assyncCounter.chpl
) can be found in$CHPL_HOME/examples/spec/Task_Parallelism_and_Synchronization/syncCounter.chpl
.If you're working from the development branch on GitHub rather than an official release, they can be found in
$CHPL_HOME/test/release/examples/spec
after you have executed amake spectests
command from the$CHPL_HOME
directory.