At Inverted Software we do lots of Software refactoring and optimization.
We regularly get requests from customers in the form of: “My system is slow, can you help?”
Software refactoring is an art and a vast subject. In this blog post I am going to talk about a very small portion of it called Single instruction, multiple data (SIMD).
SIMD is most suitable for isolated components in your system. If your system as a whole suffers from insufficient architecture, SIMD will probably not help, but, if you have a slow module, especially one that perform graphic or business calculations, SIMD can speed it up ten folds.
What is Single instruction, multiple data (SIMD)?
SIMD is the ability to run processing commands directly on the CPU.
How is that possible? Well, all software essentially runs on the CPU, however, it takes layers of compilation and application management to get there, and when it does, the code looks nothing like it should.
When we code a loop in .NET or JAVA, it will get translated to bytecode or IL, then C++, assembly and finally to zeros and ones. Of course by that time it is immensely bloated, so if it should take the CPU 10 cycles to perform the loop, now it might get done in 200 cycles or more!
The good news is that we can skip the process altogether and “go” directly to the CPU.
Modern CPUs have about 30 sets of commands we can invoke directly to create small instruction sets that will form a code block and even run in parallel on all of our cores. CPUs queue our instructions and run them on available cores for maximum performance.
Sounds too good to be true! How can we do this?
Many programming languages have started to include Vectors packages. A Vector package communicates directly with the Operating System, which in turn, sends messages to the CPU.
How is this done?
Well if your code looks something like this:
float values = GetValues();
float increment = GetIncrement();
// Perform increment operation as manual loop:
for (int i = 0; i < values.Length; i++)
values[i] += increment;
To vectorize it, you will have to write something in the style of:
Vector<float> values = GetValues();
Vector<float> increment = GetIncrement();
// Perform addition as a vector operation:
Vector<float> result = values + increment;
Looks complicated? Not to worry. At Inverted Software we have experts that will insure your product is “vectorized” correctly and is performance tuned.
Get the maximum out of your software and hardware. Let the experts at Inverted Software fine tune your systems. We have great architects that can troubleshoot and resolve any issue.
Contact us today!