# No performance improvement with FloatVectorOperations

**URL:** <https://forum.juce.com/t/no-performance-improvement-with-floatvectoroperations/26255>\
**Category:** General JUCE discussion\
**Created:** [February 3, 2018, 10:15pm UTC](https://forum.juce.com/t/no-performance-improvement-with-floatvectoroperations/26255 "2018-02-03T22:15:19Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [March 15, 2023, 3:52pm UTC](https://forum.juce.com/t/no-performance-improvement-with-floatvectoroperations/26255/30 "2023-03-15T15:52:19Z")

</div>

> [@PluginPenguin](#):
>
> But when slicing my data into sub-vectors that exactly matched a CPU cache line size and then iterating over these sub vectors in a for loop, while doing the actual computation on these sub vectors with FloatVectorOperations caused a huge performance boost.

There was a SIMD talk I saw I’ll have to dig up which talked about avoiding vector sizes that are exact  
powers of 2 for best performance.

I tried 511 items here instead of 512 and it seems to put vDSP\_vsmsma back on top on my machine:

```auto
benchmark name samples iterations estimated
                                     mean low mean high mean
                                     std dev low std dev high std dev
-------------------------------------------------------------------------------
loop 100 401 2.2456 ms 
                                        56.2942 ns 56.2568 ns 56.3472 ns 
                                       0.225151 ns 0.172133 ns 0.331674 ns 
                                                                               
FloatVectorOperations copy then add 100 279 2.2599 ms 
                                         83.288 ns 81.6942 ns 85.7759 ns 
                                        10.0145 ns 7.1822 ns 14.0543 ns 
                                                                               
vDSP_vsmsma 100 472 2.2656 ms 
                                         47.617 ns 47.361 ns 48.3056 ns 
                                        1.96311 ns 0.832855 ns 3.89036 ns 
                                                                            

```

> **code**
>
> ```auto
> SECTION ("nerd sniped")
> {
> // use audio blocks to ensure alignment
> juce::HeapBlock<char> aData;
> juce::dsp::AudioBlock<float> a = { aData, 1, 511 };
> 
> juce::HeapBlock<char> bData;
> juce::dsp::AudioBlock<float> b = { bData, 1, 511 };
> 
> juce::HeapBlock<char> resultData;
> juce::dsp::AudioBlock<float> result = { resultData, 1, 511 };
> float alpha = 3.5f;
> float beta = 1.2f;
> 
> BENCHMARK ("loop")
> {
> for (int i = 0; i < (int) result.getNumSamples(); ++i)
> {
> result.setSample(0, i, alpha * a.getSample(0, i) + beta * b.getSample(0, i));
> }
> return result.getChannelPointer(0);
> };
> 
> BENCHMARK ("FloatVectorOperations copy then add")
> {
> juce::FloatVectorOperations::copyWithMultiply (result.getChannelPointer(0), a.getChannelPointer(0), alpha, result.getNumSamples());
> juce::FloatVectorOperations::addWithMultiply (result.getChannelPointer(0), b.getChannelPointer(0), beta, result.getNumSamples());
> return result.getChannelPointer(0);
> };
> 
> BENCHMARK ("vDSP_vsmsma")
> {
> vDSP_vsmsma (a.getChannelPointer(0), 1, &alpha, b.getChannelPointer(0), 1, &beta, result.getChannelPointer(0), 1, result.getNumSamples());
> return result.getChannelPointer(0);
> };
> 
> ```

---

_[View the full topic](https://forum.juce.com/t/no-performance-improvement-with-floatvectoroperations/26255)._
