Serial and Parallel Code
Serial code uses a single thread of execution working on a single data item at any one time. Sorting cards using one worker is an example of serial computation. Some parts of a parallel program may still be serial code. For instance, when the manager was partitioning the data by card suit, this was like a serial code section because none of the workers could start until the partitioning was done.
Parallel code has more than one thing happening at a time. In our card sorting example, this corresponds to having multiple workers active at once. In computing this could be:
- Multiple threads of execution in a single process (Multiple card sorters working at one table).
- Multiple processes all working on the same problem (Multiple workers, each at their own table).
- A single thread of execution operating on multiple data items simultaneously (e.g., by issuing vector instructions on a CPU).
- Any combination of the above.