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

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® Integrated Performance Primitives
- ippsMaxIndx_32f bug with -INFINITY

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

Rodney_T_

Beginner

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

06-30-2017
12:32 AM

154 Views

ippsMaxIndx_32f bug with -INFINITY

**Bug: **

Calling ippsMaxIndx_32f on array containing values initialised to -Infinity will sometimes fail.

**Detail:**

Calling ippsMaxIndx_32f on an array containing values initialised to -Infinity (00 00 80 ff), will set pIndx to len, for length values >33 and where (len % 8) != 0. In these cases the returned IppStatus is set to ippStsNoErr. Attempting to use the returned index on the original array results in seg fault / out of range exception.

**Environment:**

- IPP Version 9.0.3
- Visual Studio 2015
- x64 Debug build
- Windows 7 64-bit
- Intel Core i7-2600

**To reproduce:**

#include "stdafx.h" #include <ipp.h> #include <limits> #include <iostream> #include <assert.h> bool testMaxIndx_32f(int length, float value) { Ipp32f max = 0.0f; int maxIdx = 0; Ipp32f* tmpArray; tmpArray = ippsMalloc_32f(length); for (int i = 0; i < length; ++i) tmpArray= value; IppStatus status = ippsMaxIndx_32f(tmpArray, length, &max, &maxIdx); assert(status == ippStsNoErr); ippsFree(tmpArray); return (maxIdx != length); } int main() { // Test using IPP alloc for (int len = 1; len < 100; ++len) { if (!testMaxIndx_32f(len, -INFINITY)) std::cout << "ippsMaxIndx error for -INFINITY and length " << len << " (Ipp Alloc)" << std::endl; } }

**Output (trimmed):**

ippsMaxIndx error for -INFINITY and length 34 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 35 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 36 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 37 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 38 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 39 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 41 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 42 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 43 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 44 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 45 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 46 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 47 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 49 (Ipp Alloc)

ippsMaxIndx error for -INFINITY and length 50 (Ipp Alloc)

**Notes:**

The corresponding error exists with ippsMinIndx_32f and positive INFINITY. I have not tested if the same issue occurs with other datatypes (64f/16s/32s).

Link Copied

6 Replies

Zhen_Z_Intel

Employee

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

07-03-2017
09:16 PM

154 Views

Hi Rodney,

I could not reproduce your problem in IPP 9.0.3 & VS 2015. On the other hand, the name for variables/const probably could not start from minus sign, only underline and letter. The "INFINITY" is defined in cmath lib, but probably do not have "-INFINITY", I feel confused with the value you described -Infinity (00 00 80 ff). Largest value of 32bits float is 3.402823 × 10^{38} , and inf should be bigger than max value, but do not have a specified value.

Best regards,

Fiona

Rodney_T_

Beginner

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

07-04-2017
07:02 AM

154 Views

Hi Fiona,

(00 00 80 FF) is the representation of negative infinity as per IEEE-754 (https://en.wikipedia.org/

I'm confused by your response, were you unable to compile my example? Or did your application not fail the test?

If you have an email address I can send you a VS2015 solution.

Cheers, Rodney

Rodney_T_

Beginner

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

07-04-2017
06:18 PM

154 Views

Rodney_T_

Beginner

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

07-04-2017
08:28 PM

154 Views

For array lengths 1 through 33 it behaves as I expected from the documentation:

- pMax contains the value '-inf' (00 0 80 FF)

- pIndx contains the value 0, ie the first index from the beginning with equal maximum element

However when the array length reaches 34, and beyond:

- pMax contains the value '-3.40282347e+38' (max float value that is NOT infinity)

- pIndx contains the value 34, ie an out of bounds index (although in some instances it returns an index of 4).

- The returned status is ippStsNoErr

When it reaches array length of 40, and multiples of 8, it again behaves as I expect:

- pMax contains the value '-inf' (00 0 80 FF)

- pIndx contains the value 0, ie the first index from the beginning with equal maximum element

Ivan_Z_Intel

Employee

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

07-05-2017
10:03 AM

154 Views

Hi all,

There are the bugs in functions ipps{Min|Max}Indx_{32f|64f}. The functions run incorrectly if all elements of source vector equal Inf (-Inf) and vector length is more 34. For types 16s, 32 these functions run correctly.

This bug will be fixed in the next versions.

Thank you very much for the example of incorrect work of these functions.

Rodney_T_

Beginner

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

07-05-2017
05:47 PM

154 Views

Hi Ivan, thanks for your response. I look forward to the fix in the next release.

- 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.