F.2.2 OpenCL 2.0 built-in functions

Several new built-in functions are added in OpenCL 2.0.

OpenCL 2.0 adds many functions for atomic operations, compatible with the C11 standard.

Atomic functions are useful for both when multiple threads on the GPU access the same data, and when GPU and CPU use shared data via SVM in fine-grained mode.

The following table shows examples of the main types of atomic functions:

Table F-2 Atomic operation functions

Function name Description
atomic_fetch_add() Add a value to an object, return the value of object before the addition.
atomic_fetch_sub() Subtract a value from an object, return the value before the subtraction.
atomic_load() Load, that is, fetch the value of the atomic object.
atomic_store() Store a new value in an atomic object.
atomic_compare_exchange_strong() Compare the value of an atomic object to an expected value, and replace with the desired if a match. Returns true 1 if the value was replaced, or false 0 when the expected value is not matching - expected value is updated to match the current value of the atomic object.
atomic_compare_exchange_weak() Same as previously, but can sometimes fail even if the object matches the desired value.
atomic_flag_test_and_set() Atomically fetch the current flag value, set it to true (1) and return the value before it was set.

Device execution functions support creating new work, creating, setting, and destroying events. They also support constructing ndrange sets.

The following functions support device execution:

Functions for pipes enable the CL kernel to read, write individual or multiple packets, and check the current status of a pipe.

The following functions support pipes:

Non-ConfidentialPDF file icon PDF version101574_0302_00_en
Copyright © 2019 Arm Limited or its affiliates. All rights reserved.