Parallel random-access machine

In computer science, a parallel random-access machine is a shared-memory abstract machine. As its name indicates, the PRAM was intended as the parallel-computing analogy to the random-access machine. In the same way that the RAM is used by sequential-algorithm designers to model algorithmic performance, the PRAM is used by parallel-algorithm designers to model parallel algorithmic performance. Similar to the way in which the RAM model neglects practical issues, such as access time to cache memory versus main memory, the PRAM model neglects such issues as synchronization and communication, but provides any number of processors. Algorithm cost, for instance, is estimated using two parameters O and O.

Read/write conflicts

Read/write conflicts, commonly termed interlocking in accessing the same shared memory location simultaneously are resolved by one of the following strategies:
  1. Exclusive read exclusive write —every memory cell can be read or written to by only one processor at a time
  2. Concurrent read exclusive write —multiple processors can read a memory cell but only one can write at a time
  3. Exclusive read concurrent write —never considered
  4. Concurrent read concurrent write —multiple processors can read and write. A CRCW PRAM is sometimes called a concurrent random-access machine.
Here, E and C stand for 'exclusive' and 'concurrent' respectively. The read causes no discrepancies while the concurrent write is further defined as:
Several simplifying assumptions are made while considering the development of algorithms for PRAM. They are:
  1. There is no limit on the number of processors in the machine.
  2. Any memory location is uniformly accessible from any processor.
  3. There is no limit on the amount of shared memory in the system.
  4. Resource contention is absent.
  5. The programs written on these machines are, in general, of type SIMD.
These kinds of algorithms are useful for understanding the exploitation of concurrency, dividing the original problem into similar sub-problems and solving them in parallel. The introduction of the formal 'P-RAM' model in Wyllie's 1979 thesis had the aim of quantifying analysis of parallel algorithms in a way analogous to the Turing Machine. The analysis focused on a MIMD model of programming using a CREW model but showed that many variants, including implementing a CRCW model and implementing on an SIMD machine, were possible with only constant overhead.


PRAM algorithms cannot be parallelized with the combination of CPU and dynamic random-access memory because DRAM does not allow concurrent access; but they can be implemented in hardware or read/write to the internal static random-access memory blocks of a field-programmable gate array, it can be done using a CRCW algorithm.
However, the test for practical relevance of PRAM algorithms depends on whether their cost model provides an effective abstraction of some computer; the structure of that computer can be quite different than the abstract model. The knowledge of the layers of software and hardware that need to be inserted is beyond the scope of this article. But, articles such as demonstrate how a PRAM-like abstraction can be supported by the explicit multi-threading paradigm and articles such as demonstrate that a PRAM algorithm for the maximum flow problem can provide strong speedups relative to the fastest serial program for the same problem. The article demonstrated that PRAM algorithms as-is can achieve competitive performance even without any additional effort to cast them as mutli-threaded programs on XMT.

Example code

This is an example of SystemVerilog code which finds the maximum value in the array in only 2 clock cycles. It compares all the combinations of the elements in the array at the first clock, and merges the result at the second clock. It uses CRCW memory; m <= 1 and maxNo <= data are written concurrently. The concurrency causes no conflicts because the algorithm guarantees that the same value is written to the same memory. This code can be run on FPGA hardware.

module FindMax #
typedef enum bit State;

State state;
bit m;
int i, j;

always_ff @ begin
if begin
for m <= 0;
state <= COMPARE;
end else begin
COMPARE: begin
for begin
for begin
if m <= 1;
state <= MERGE;

MERGE: begin
for begin
if maxNo <= data;
state <= DONE;