Quantcast
Channel: Intel® Software - Intel® Integrated Performance Primitives
Viewing all articles
Browse latest Browse all 1489

ippiDivC_16u_C1RSfs does not obey rounding

$
0
0

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[i] << "/"<< denominator << " = "<< float(v[i])/float(denominator) << "\t IppRound "<< r[i] <<  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

 


Viewing all articles
Browse latest Browse all 1489

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>