- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following loop that I would like to optimize. Are there any IPP function for each of these statements in the for loop?
double fast_product_sum(int n, double *a, int* indexes, double* b, double* c)
{
double sum = 0.0;
for (int i = 0; i < n; i++)
{
c = a + b[indexes];
sum += a + b[indexes];
}
return sum;
}
I apprieciate any help in this matter.
Regards
Chris
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please look at a subset of IPP functions called as Vector Math functions. These functions allow to do add, subtract and multiply operations for every element of the source vector and highly optimized.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Chris, you're calculating the sum of a + b[ indexes ] twice:
...
for (int i = 0; i < n; i++)
{
c = a + b[ indexes ];
sum += a + b[ indexes ];
}
...
and if input arrays are very large ( for example, greater than 4MB ), indexes array has unordered/random values and all input arrays don't fit into L3 cache line then a performance of calculations will be affected.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page