//
an array of Foo elements
device Foo *my_info;
Since texture objects are always allocated from the device address space, the
device
address
attribute is not needed for texture types. The elements of a texture object cannot be directly
accessed. Functions to read from and write to a texture object are provided.
4.2.2
threadgroup Address Space
Threads are organized into
threadgroups. Threads in a threadgroup cooperate by sharing data
through
threadgroup
memory and by synchronizing their execution to coordinate memory
accesses to both
device
and
threadgroup
memory. The threads in a given threadgroup
execute concurrently on a single compute unit on the GPU. A GPU may have multiple compute
units. Multiple threadgroups can execute concurrently across multiple compute units.
The
threadgroup
address space name is used to allocate variables used by a kernel function.
Variables declared in the
threadgroup
address space
cannot be used in graphics functions.
Variables allocated in the
threadgroup
address space in a kernel function are allocated for
each threadgroup executing the kernel, are shared by all threads in a threadgroup and exist only
for the lifetime of the threadgroup that is executing the kernel.
Variables allocated in the
threadgroup
address space for a mid-render kernel function are
allocated for each threadgroup executing the kernel and are persistent across mid-render and
fragment kernel functions over a tile.
The example below shows how variables allocated in the
threadgroup
address space can be
passed either as arguments or be declared inside a kernel function. (The
[[threadgroup(0)]]
attribute in the code below is explained in section 4.3.1.)
kernel void
my_kernel(threadgroup float *a [[threadgroup(0)]],
…)
{
// A float allocated in the
threadgroup address space
threadgroup float x;
// An array of 10
floats allocated in the
// threadgroup address space
threadgroup float b[10];
…
}
4.2.2.1
SIMD-groups and Quad-groups
2017-9-12 | Copyright © 2017 Apple Inc. All Rights Reserved.
Page of
56
174