Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

ippiDivC_16u_C1RSfs does not obey rounding

Ockham_s_Razor
Beginner
1,021 Views

The IPP image documentation for Integer Result Scaling, referenced from ippiDivC_16u_C1RSfs, states

"The result is rounded off to the nearest even integer number"

However, under windows 10, Intel Core i9, Version: 2020.0.0 Gold, the following program, VS2017 compiles as C++17

#include <iostream>
#include <vector>
#include "ipp.h"

int main()
{
	std::vector<Ipp16u> v = { 91, 105, 35, 175, 63, 133 };
	auto r = v;
	const Ipp16u denominator = 14;
	const auto status = ippiDivC_16u_C1RSfs(v.data(), v.size() * sizeof(ipp16u), denominator, r.data(), r.size() * sizeof(ipp16u), { int(v.size()), 1 }, 0);
	if (status != 0)
	{
		return -1;
	}

	std::cout << "Version: " << IPP_VERSION_STR << std::endl;
	
	for (auto i = 0; i < v.size(); i++)
	{
		std::cout << i << ") " << v << "/" << denominator << " = " << float(v)/float(denominator) << "\t IppRound " << r <<  std::endl;
	}

	return 0;
}

returns

Version: 2020.0.0 Gold
0) 91/14 = 6.5   IppRound 7
1) 105/14 = 7.5  IppRound 8
2) 35/14 = 2.5   IppRound 2
3) 175/14 = 12.5 IppRound 13
4) 63/14 = 4.5   IppRound 4
5) 133/14 = 9.5  IppRound 10

Note for 0, round should be 6 NOT 7, for 3, the round should be 12 not 13.  The others are just examples where the round is correct.

So is the documentation incorrect and the result is some weird hardware issue?  If so the documentation should be corrected.

14 is special, e.g., if you divide the interval [0..65535] by n, 14 is the smallest that results in an error.  If you test all positive n's (65534) you find 2047 such divisors that have at least one error.   Smallest 14, largest 32698.

Thanks for any input

 

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
1,021 Views

Thanks for the report. It looks like an issue. We will check and fix.

0 Kudos
Gennady_F_Intel
Moderator
1,013 Views

the issue is escalated and this forum thread will be updated accordingly the investigation results.


0 Kudos
Reply