|
|
|
|
|
by physicsguy
1060 days ago
|
|
Vector instructions speed up things like: for (int i = 0; i < N; i++)
{
a[i] = b[i]*c[i];
}
Effectively, they let you do this in chunks of 2, 4 or 8 elements in a single instruction instead of element by element. Usually the clock speed of the processor drops slightly while executing these instructions but not so much as to make it slower than not having the instruction.New instruction sets usually do two things - add support for new operations, and widen the registers and allow you to perform the operation on more elements at a time. If you’re writing in a high level language, you’ll only really see performance improvements if your interpreter or library takes advantage of them. For e.g. the Python library NumPy makes good use of vectorisation. In terms of writing low level code, simple loops are often auto-vectorised by the compiler so you often see a sort of odd style where a loop doing many things is split up so the compiler can deal with it. You often end up having to run the code through something like VTune to work out whether a particular loop has actually vectorised. |
|