1

IPP is a C library, with hundreds of functions like this:

IppStatus ippiTranspose_8u_C1R(const Ipp8u* pSrc, int srcStep,
                               Ipp8u* pDst, int dstStep,
                               IppiSize roiSize));

To be able to call these functions in a more convenient, safe and consistent way, we need a C++ wrapper function for each C function. For example:

void ippiTranspose(const Image<Ipp8u> &src, Rect srcRect, Image<Ipp8u> &dst, Point dstPos)
{
  if (!src.valid()) throw "Invalid src";
  if (!dst.valid()) throw "Invalid dst";
  Rect srcRoi = srcRect.isEmpty() ? src.rect() : srcRect;
  if (!src.rect().contains(srcRoi)) throw "Invalid src rect";
  Rect dstRoi = Rect(dstPos, srcRoi.size());
  if (!dst.rect().contains(dstRoi)) throw "Invalid dst rect";
  IppStatus st = ippiTranspose_8u_C1R(&src.at(srcRoi.topLeft()), src.step(), &dst.at(dstRoi.topLeft()), dst.step(), toIppiSize(srcRoi.size());
  if (st < 0) throw "ippiTranspose_8u_C1R failed";
}

There are logical patterns, which can be applied to all the functions in IPP.

How to automatically generate all these wrappers?

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Hristo Hristov
  • 4,021
  • 4
  • 25
  • 37

3 Answers3

2

There are some kind of wrappers, provided by Intel, which are well hidden in ipp-samples for windows only. I'm using the latest 7.0 beta version. They provide C++ headers, generated by a perl script, which are supposed to be used as a C++ wrappers. The "wrapper" for the ippiTranspose_8u_C1R function in the question is this:

 static inline IppStatus ippiTranspose_C1R( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize) {
   return ippiTranspose_8u_C1R( pSrc, srcStep, pDst, dstStep, roiSize );
 }

This is just a shorter version of the function call.

What I expect from a good C++ wrapper for a C function:

  • map C-like params to C++ (objects, templates)
  • check if the input params are valid
  • check if the result is a success, error or warning
  • error handling using exceptions

We need a real solution for the C++ world, Intel!

I am currently working on a program, which automatically generates wrappers like the example in the question, and the things look nice.

Thanks to Ross for pointing the solution from Intel.

Hristo Hristov
  • 4,021
  • 4
  • 25
  • 37
2

Better late than never. IPP 2017 has an extension package with full-blown C++ API. The preview had small functionality coverage, but it may have been extend for the gold release. https://software.intel.com/en-us/articles/intel-ipp-integration-wrappers

plswork04
  • 589
  • 6
  • 11
LupusTR3
  • 21
  • 2
0

Look at the examples there is ippi.hpp file in "language" examples section. It is C++ wrapper.

Ross
  • 2,079
  • 2
  • 22
  • 26
  • Also, in examples of beta 7.0 version there is more complete implementation. – Ross Aug 25 '10 at 09:29
  • Thanks, I will post my comment as a new answer, because source code can't be posted in a comment. – Hristo Hristov Aug 26 '10 at 06:35
  • Hmm, I have IPP installed, but I can't seem to find `ippi.hpp` in my `ipp-samples.7.1.0.011` or `/opt/intel` directories. I do have `ipp.h` and other non-C++ headers, though. – solvingPuzzles Nov 20 '12 at 02:27