I am trying to determine if the Accelerate Framework can help speed up a calculation my app has to perform. Let's say I have the following arrays:
invoice[0..n]
, an array of doubles containing invoice valuesweek[0..n]
, an array of integers, whereweek[x]
holds the week-of-yearinvoice[x]
was billed.
The number of invoices per week is variable. I have tens of thousands of invoices. Both arrays are ordered by week.
Is there any way the Accelerate framework can help me calculate how much was billed per week?
So, for example, if:
invoice = [10.0, 15.0, 10.0, 25.0, 40.0, x, ...]
week = [ 0, 0, 0, 1, 1, 2, ...]
the result should be: [35.0, 65.0, ...]
I have browsed the documentation, and it does not seem to have this capability but, since I am completely new to it, there may be some trick I am missing.
Have you tried something similar:
Now obviously, there is a bit of work you need to do on the array setup.
The reason I am asking if you tried C logic is because I usually find that logical C + compiler optimization usually gives better results than C alone - since this is what the compiler is doing in the background anyway...And probably optimizing better than we can....
Compiler optimization: project -> build settings -> optimization level -> change Debug and release to "-Os".
I would start with that and measure the different mach times using different optimizations.
If it is still slow, I would try vDSP in Accelerate framework:
Accelerate Framework API
I think the problem you will have with any matrix calculations is that you have a variable stride so you can't use something like vDSP_sve.
Accelerate framework and vector math optimization is based on being able to use a static number of elements to fill the registers and to compute at the same time. A variable stride negates that.
Hope some of that helps.