Closed ytgui closed 5 years ago
shared memory
constant memory
texture memory
more Texture memory is optimized for 2D spatial locality (where it gets its name from). You can kind of think of constant memory as taking advantage of temperal locality.
The benefits of texture memory over constant memory can be summarized as follows:
more 2
https://medium.com/@smallfishbigsea/basic-concepts-in-gpu-computing-3388710e9239 https://www.quora.com/What-is-a-warp-and-how-is-it-different-from-a-thread-block-or-wave-in-CUDA
// -----
// cuda: grid -> grid -> thread, __shared__
// cl: kernel -> work_group -> work_item, __local
// -----
// size_t tid = get_local_id(0);
// size_t tid = threadIdx.x;
// -----
// size_t gid = get_global_id(0);
// size_t gid = blockIdx.x * blockDim.x + threadIdx.x;
// -----
// size_t window = get_local_size(0);
// size_t window = blockDim.x;
// -----
// size_t stride = get_global_size(0);
// size_t stride = gridDim.x * blockDim.x;
// -----
OpenCL Memory Model
Overview
Description
OpenCL defines a four-level memory hierarchy for the compute device:
Not every device needs to implement each level of this hierarchy in hardware. Consistency between the various levels in the hierarchy is relaxed, and only enforced by explicit synchronization constructs, notably barriers.
Devices may or may not share memory with the host CPU.[13] The host API provides handles on device memory buffers and functions to transfer data back and forth between host and devices.