C++ Vector class library
Posted: 2019-12-30, 7:15:57
The C++ Vector Class Library (VCL) is a tool that makes it easy to do multiple calculations simultaneously.
Modern microprocessors have vector registers that allow you to do multiple operations in a single instruction. This principle is called SIMD (Single Instruction Multiple Data).
The vector registers can be 128, 256, or 512 bits long. Microprocessors with the AVX512 instruction set can pack sixteen floating point values (using 32 bits each) into a single 512-bit register. This allows you to do sixteen floating point operations in a single instruction. You can pack even more values into a single vector register if you are using integers of less than 32 bits each. The SIMD principle has the potential to give you a tremendous improvement in calculation speed.
The latest microprocessors have thousands of different SIMD instruction, and it is quite complicated to use them. The VCL library provides a simple and easy interface to the SIMD instructions. For example, if a and b are vectors containing sixteen floating point values each, then you can add them simply by writing c = a + b. This will generate a single machine instruction that does all sixteen additions at once, using the AVX512 instruction set. If the vector registers are shorter, then you will need more instructions. For example, the same code will generate two instructions if your computer has the AVX instruction set with 256-bit vector registers. VCL allows you to compile for different microprocessors with different instruction set extensions from the same C++ source code. All you have to do is to specify the instruction set on the compiler command line.
A library of mathematical functions is included. The latest version of VCL can be downloaded from Github at https://github.com/vectorclass/version2/releases
The code is free and open source.
Modern microprocessors have vector registers that allow you to do multiple operations in a single instruction. This principle is called SIMD (Single Instruction Multiple Data).
The vector registers can be 128, 256, or 512 bits long. Microprocessors with the AVX512 instruction set can pack sixteen floating point values (using 32 bits each) into a single 512-bit register. This allows you to do sixteen floating point operations in a single instruction. You can pack even more values into a single vector register if you are using integers of less than 32 bits each. The SIMD principle has the potential to give you a tremendous improvement in calculation speed.
The latest microprocessors have thousands of different SIMD instruction, and it is quite complicated to use them. The VCL library provides a simple and easy interface to the SIMD instructions. For example, if a and b are vectors containing sixteen floating point values each, then you can add them simply by writing c = a + b. This will generate a single machine instruction that does all sixteen additions at once, using the AVX512 instruction set. If the vector registers are shorter, then you will need more instructions. For example, the same code will generate two instructions if your computer has the AVX instruction set with 256-bit vector registers. VCL allows you to compile for different microprocessors with different instruction set extensions from the same C++ source code. All you have to do is to specify the instruction set on the compiler command line.
A library of mathematical functions is included. The latest version of VCL can be downloaded from Github at https://github.com/vectorclass/version2/releases
The code is free and open source.