Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

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

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-25-2010
07:16 AM

157 Views

Sum of powers

P.S. I need this to compute p-norm of the vector.

Link Copied

12 Replies

Naveen_G_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-25-2010
08:03 AM

157 Views

Hi,

Here are list of power functions implemented in IPP as per IEEE-754 standard.

http://software.intel.com/sites/products/documentation/hpc/ipp/ipps/ipps_ch12/ch12_Intro.html

Regards,

Naveen Gv

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-25-2010
08:21 AM

157 Views

But I need to compute the following:

s = pow(a[0], p) + pow(a[1], p) + ... + pow(a[n - 1], p)

To calculate such a sum I need an extra space because I can't destroy the original content of the array:

1. Use **Powx** function to compute powers:

b* = pow(a**, p), i = 0 .. n - 1*

2. Use **Sum**function to compute sum:

s = b[0] + b[1] + ... + b[n - 1]

In certain situations I should also compute absolute values before computing powers.

The question was whether I could compute such sums without utilizing an extra space. Do you have any suggestions how to do it?

Chao_Y_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-25-2010
07:08 PM

157 Views

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

Chao

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-26-2010
08:18 AM

157 Views

Quoting Chao Y (Intel)

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

Chao

Chao_Y_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-26-2010
07:44 PM

157 Views

MKL vdPowx( n, a, b, y ) support in-place operation. You may call this function, put the out-put value into a*, then sum the a value. *

Thanks,

Chao

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
05:02 AM

157 Views

Quoting Chao Y (Intel)

MKL vdPowx( n, a, b, y ) support in-place operation. You may call this function, put the out-put value into a*, then sum the a value. *

Thanks,

Chao

double sum = 0.0;

for (int i = 0; i < n; ++i)

{

sum += pow(a*, x);*

}

But I was hoping to find a way to do it faster by using MKL and IPP.

Vladimir_Dudnik

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
10:29 AM

157 Views

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

Vladimir

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
10:52 AM

157 Views

Quoting Vladimir Dudnik (Intel)

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

Vladimir

Currently I have several alternatives:

1. Allocate full length array and use MKL/IPP in the way similar to the one you proposed.

2. Do it manually. No extra space is required.

3. Allocate small array and compute the sum of powers by blocks (thanks to Chao Y for proposition).

It seems strange that such libraries like MKL and IPP doesn't have required functionality.

Vladimir_Dudnik

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
11:07 AM

157 Views

Vladimir

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
11:20 AM

157 Views

P. S. By the way, Intel IPP library has routines for computing L1, L2 or infinity norm, but has no routine to compute the general case (I mean p-norm).

Thomas_B_3

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-28-2010
12:42 AM

157 Views

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJ

Vitali_Haravy

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-28-2010
01:37 AM

157 Views

Quoting TJ04

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJ

I am afraid that I'm bound to MKL+IPP (we don't use Intel Compiler), but in any case thanks for information.

Best regards,

Vitali.

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

For more complete information about compiler optimizations, see our Optimization Notice.