2.6 Concurrency

Concurrent applications have multiple operations in progress at the same time. These can operate in parallel or in serial through the use of a time sharing system.

In a concurrent application, multiple tasks attempt to share the same data. Access to this data must be managed to prevent complex problems such as race conditions, deadlocks, and livelocks.

Race conditions
A race condition occurs when two or more threads try to modify the value of one variable at the same time. In general, the final value of the computation will always produce the same value, but when a race condition occurs, the variable can get a different value that depends on the order of the writes.
A deadlock occurs when two threads become blocked by each other and neither thread can make progress. This can happen when each thread obtains a lock that the other thread requires.
A livelock is similar to deadlock, but the threads keep running. Because of the lock, the threads can never complete their tasks.

Concurrent applications require concurrent data structures. A concurrent data structure is a data structure that enables multiple tasks to gain access to the data with no concurrency problems.

Data parallel applications use concurrent data structures. These are the sorts of data structures that you typically use in OpenCL.

OpenCL includes atomic operations to help manage interactions between threads. Atomic operations provide one thread exclusive access to a data item while it modifies it. The atomic operation enables one thread to read, modify, and write the data item with the guarantee that no other thread can modify the data item at the same time.


OpenCL does not guarantee the order of operation of threads. Threads can start and finish in any order.
Non-ConfidentialPDF file icon PDF version101574_0302_00_en
Copyright © 2019 Arm Limited or its affiliates. All rights reserved.