What is vectorization?
Vectorization is a parallel computing method that compiles repetitive program instructions into a single vector (combination of multiple datasets), which is then executed simultaneously and maximizes computer speed. Vectorization is an example of single instruction, multiple data (SIMD) processing because it executes a single operation (e.g., addition, division) over a large dataset. Today, vectorization is a critical micro-process and universally present in modern computers.
How does vectorization work?
Vectorization starts with the understanding the downside of scalar programming—the process of operating on a dataset sequentially. For example, a developer writes a for-loop to add two sets of numbers [a,b] to get a result [c]. In early computing, computers did just that, repeating the addition of a and b pairs one after another. Because these processes take place sequentially, the time needed to complete the program can be massive, depending on the datasets’ size.
This excess runtime is no problem for most users for a small set of numbers, but the simple repeated instruction means lost time and energy when working with large datasets. Using applications that automatically detect and convert scalar instructions into vectorized implementations, computers can drastically decrease runtime processing. Most computers today contain automatic vectorization abilities and multi-core CPUs, which mean order of magnitude performance gains.
Examples of vectorization
- NumPy. Python is known as one of the most development-friendly languages yet struggles with runtime for simple arithmetic. The NumPy tool gives Python developers the vectorization abilities of C or Fortran. NumPy makes vectorization easy and runtime smooth for developers by enabling parallel operations, list creation for NumPy arrays, and memory locality.
- High-performance computing. An essential feature of modern computing is the use of parallel processing algorithms that divide and conquer tasks. Where before vectorization exclusively lived in supercomputers, parallel computing is now the standard for global computer architectures.
- Fortran. Initially developed for mathematical and scientific applications, Fortran once was the most popular high-level programming language. Still famous for working with large datasets, Fortran is renowned for its vector and matrix processing capabilities.