Scratchpad memory (SPM), also known as scratchpad, scratchpad RAM or local store in
computer
A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
terminology, is a high-speed internal memory used for temporary storage of calculations, data, and other work in progress. In reference to a
microprocessor (or
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
), scratchpad refers to a special high-speed memory used to hold small items of data for rapid retrieval. It is similar to the usage and size of a scratchpad in life: a pad of paper for preliminary notes or sketches or writings, etc.
In some systems it can be considered similar to the
L1 cache
A CPU cache is a hardware cache used by the central processing unit (CPU) of a computer to reduce the average cost (time or energy) to access data from the main memory. A cache is a smaller, faster memory, located closer to a processor core, which ...
in that it is the next closest memory to the
ALU
ALU, Alu or alu may refer to:
Computing and science
;Computing
*Arithmetic logic unit, a digital electronic circuit
;Biology
* Alu sequence, a type of short stretch of DNA
*'' Arthrobacter luteus'', a bacterium
Organizations
* Abraham Lincoln ...
after the
processor registers, with explicit instructions to move data to and from
main memory
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a computer ...
, often using
DMA
DMA may refer to:
Arts
* ''DMA'' (magazine), a defunct dance music magazine
* Dallas Museum of Art, an art museum in Texas, US
* Danish Music Awards, an award show held in Denmark
* BT Digital Music Awards, an annual event in the UK
* Doctor of M ...
-based data transfer. In contrast to a system that uses caches, a system with scratchpads is a system with
non-uniform memory access (NUMA) latencies, because the memory access latencies to the different scratchpads and the main memory vary. Another difference from a system that employs caches is that a scratchpad commonly does not contain a copy of data that is also stored in the main memory.
Scratchpads are employed for simplification of caching logic, and to guarantee a unit can work without main memory contention in a system employing multiple processors, especially in
multiprocessor system-on-chip A multiprocessor system on a chip (, ' or ) is a system on a chip (SoC) which includes multiple microprocessors. As such, it is a multi-core system on a chip.
MPSoCs are usually targeted for embedded applications. It is used by platforms that con ...
for
embedded systems. They are mostly suited for storing temporary results (as it would be found in the CPU stack) that typically wouldn't need to always be committing to the main memory; however when fed by
DMA
DMA may refer to:
Arts
* ''DMA'' (magazine), a defunct dance music magazine
* Dallas Museum of Art, an art museum in Texas, US
* Danish Music Awards, an award show held in Denmark
* BT Digital Music Awards, an annual event in the UK
* Doctor of M ...
, they can also be used in place of a cache for mirroring the state of slower main memory. The same issues of
locality of reference apply in relation to efficiency of use; although some systems allow strided DMA to access rectangular data sets. Another difference is that scratchpads are explicitly manipulated by applications. They may be useful for
realtime applications
Real-time computing (RTC) is the computer science term for hardware and software systems subject to a "real-time constraint", for example from event to system response. Real-time programs must guarantee response within specified time constrai ...
, where predictable timing is hindered by cache behavior.
Scratchpads are not used in mainstream desktop processors where generality is required for
legacy software
In computing, a legacy system is an old method, technology, computer system, or application program, "of, relating to, or being a previous or outdated computer system", yet still in use. Often referencing a system as "legacy" means that it paved ...
to run from generation to generation, in which the available on-chip memory size may change. They are better implemented in embedded systems, special-purpose processors and
game consoles, where chips are often manufactured as
MPSoC A multiprocessor system on a chip (, ' or ) is a system on a chip (SoC) which includes multiple microprocessors. As such, it is a multi-core system on a chip.
MPSoCs are usually targeted for embedded applications. It is used by platforms that c ...
, and where software is often tuned to one hardware configuration.
Examples of use
*
Fairchild F8 of 1975 contained 64 bytes of scratchpad.
*
Cyrix 6x86 is the only
x86-compatible desktop processor to incorporate a dedicated scratchpad.
*
SuperH, used in Sega's consoles, could lock cachelines to an address outside of main memory for use as a scratchpad.
* Sony's
PS1's
R3000 had a scratchpad instead of an L1 cache. It was possible to place the CPU stack here, an example of the temporary workspace usage.
*
Adapteva's Epiphany parallel
coprocessor
A coprocessor is a computer processor used to supplement the functions of the primary processor (the CPU). Operations performed by the coprocessor may be floating-point arithmetic, graphics, signal processing, string processing, cryptography o ...
features local-stores for each core, connected by a
network on a chip, with DMA possible between them and off-chip links (possibly to DRAM). The architecture is similar to Sony's Cell, except all cores can directly address each other's scratchpads, generating network messages from standard load/store instructions.
* Sony's
PS2 Emotion Engine includes a 16
KB scratchpad, to and from which DMA transfers could be issued to its GS, and main memory.
*
Cell's SPEs are restricted purely to working in their "local-store", relying on DMA for transfers from/to main memory and between local stores, much like a scratchpad. In this regard, additional benefit is derived from the lack of hardware to check and update coherence between multiple caches: the design takes advantage of the assumption that each processor's workspace is separate and private. It is expected this benefit will become more noticeable as the number of processors scales into the "many-core" future. Yet because of the elimination of some hardware logics, the data and instructions of applications on SPEs must be managed through software if the whole task on SPE can not fit in local store.
* Many other processors allow L1 cache lines to be locked.
* Most
digital signal processor
A digital signal processor (DSP) is a specialized microprocessor chip, with its architecture optimized for the operational needs of digital signal processing. DSPs are fabricated on MOS integrated circuit chips. They are widely used in audio si ...
s use a scratchpad. Many past 3D accelerators and game consoles (including the PS2) have used DSPs for
vertex transformations. This differs from the stream based approach of modern GPUs which have more in common with a CPU cache's functions.
* NVIDIA's
8800 GPU running under
CUDA provides 16 KB of scratchpad (NVIDIA calls it Shared Memory) per thread-bundle when being used for
GPGPU tasks. Scratchpad also was used in later
Fermi GPU (
GeForce 400 Series).
* Ageia's
PhysX chip includes a scratchpad RAM in a manner similar to the Cell; its theory states that a cache hierarchy is of less use than software managed physics and collision calculations. These memories are also banked and a switch manages transfers between them.
* Intel's
Knights Landing processor has a 16 GB MCDRAM that can be configured as either a cache, scratchpad memory, or divided into some cache and some scratchpad memory.
*
Movidius Myriad 2, a
vision processing unit, organized as a multicore architecture with a large multiported shared scratchpad.
*
Graphcore has designed an
AI accelerator based on scratchpad memories
Alternatives
Cache control vs scratchpads
Some architectures such as PowerPC attempt to avoid the need for cacheline locking or scratchpads through the use of
cache control instructions
In computing, a cache control instruction is a hint embedded in the instruction stream of a processor intended to improve the performance of hardware caches, using foreknowledge of the memory access pattern supplied by the programmer or compiler. ...
. Marking an area of memory with "Data Cache Block: Zero" (allocating a line but setting its contents to zero instead of loading from main memory) and discarding it after use ('Data Cache Block: Invalidate', signaling that main memory didn't receive any updated data) the cache is made to behave as a scratchpad. Generality is maintained in that these are hints and the underlying hardware will function correctly regardless of actual cache size.
Shared L2 vs Cell local stores
Regarding interprocessor communication in a multicore setup, there are similarities between the Cell's inter-localstore DMA and a shared L2 cache setup as in the Intel Core 2 Duo or the Xbox 360's custom powerPC: the L2 cache allows processors to share results without those results having to be committed to main memory. This can be an advantage where the
working set for an algorithm encompasses the entirety of the L2 cache.
However, when a program is written to take advantage of inter-localstore DMA, the Cell has the benefit of each-other-Local-Store serving the purpose of BOTH the private workspace for a single processor AND the point of sharing between processors; i.e., the other Local Stores are on a similar footing viewed from one processor as the shared L2 cache in a conventional chip. The tradeoff is that of memory wasted in buffering and programming complexity for synchronization, though this would be similar to precached pages in a conventional chip. Domains where using this capability is effective include:
* Pipeline processing (where one achieves the same effect as increasing the L1 cache's size by splitting one job into smaller chunks)
* Extending the working set, e.g., a sweet spot for a merge sort where the data fits within 8×256 KB
* Shared code uploading, like loading a piece of code to one SPU, then copy it from there to the others to avoid hitting the main memory again
It would be possible for a conventional processor to gain similar advantages with cache-control instructions, for example, allowing the prefetching to the L1 bypassing the L2, or an eviction hint that signaled a transfer from L1 to L2 but not committing to main memory; however, at present no systems offer this capability in a usable form and such instructions in effect should mirror explicit transfer of data among cache areas used by each core.
See also
*
CPU cache
*
NUMA
*
MPSoC A multiprocessor system on a chip (, ' or ) is a system on a chip (SoC) which includes multiple microprocessors. As such, it is a multi-core system on a chip.
MPSoCs are usually targeted for embedded applications. It is used by platforms that c ...
Notes
References
External links
* Rajeshwari Banakar
Scratchpad Memory : A Design Alternative for Cache. On-chip memory in Embedded Systems// CODES'02. May 6–8, 2002
{{DEFAULTSORT:Scratchpad Ram
Internet culture