Announcing v0.5.0 of the Math eXtension Library (MXLib) - A C++ Wrapper for IPP

Announcing v0.5.0 of the Math eXtension Library (MXLib) - A C++ Wrapper for IPP

I'm pleased to announce a Beta version of MXLib has been posted to Sourceforge at:

https://sourceforge.net/projects/mxlib/

MXLib is a C++ wrapper around the Intel® Integrated Performance Primitives (IPP) library. The idea is to provide Scientists, Engineers, Researchers and other non full-time programmers an easy to use, high performance library of functions for scientific programming.  MXLib provides the following:

  • Most functions can be accessed with either C++ style call or a MatLab® like call. The MatLab® like function calls make it easy to port research code from a MatLab® to C++. In fact, for many projects, you can copy your MatLab® code, paste it into your C++ editor, make a few changes (adding object instantiations, work around certain MatLabTM syntax structures that aren’t supported by C++, etc.) and you’re done!

  • Automatically handles memory allocation/de-allocation and ensures that the IPP functions are called properly. Memory problems and calling IPP functions with data sets with mismatched sizes are common ways that problems occur when using IPP.

  • Greatly extends the functionality of IPP. Adds support for 64-bit data types IPP64s, Ipp64sc, Ipp64f, Ipp64fc) for matrices/images and also adds functionality found in a MatLab®, but not found in IPP.

  • Nearly seamless integration of complex and real data types into the same template objects greatly decreasing the complexity of the code.

  • Two basic object types; Vectors and Matrices. For some projects, most of your calculations are done using vectors (signal processing), others require more work with matrices. Functions for moving data between the two object types are included.

  • Functions for moving data between your C++ project and MatLab® are included.

  • Formatted console Print() functions to make it easier to examine your data.

  • Makes it easy to access IPP functions that have not yet been integrated into MXLib. Let MXLib handle the memory allocation/de-allocation for you then access the data inside the MXLib objects when you need to make your own call to an IPP function.

  • Makes it much easier to work with complex data types in IPP by adding operators, abs(), angle(), set to zero, etc. functions.

  • Uses exception handling that automatically types to the console where the exception or IPP error occurred and the chain of functions that led to the error similar to how errors are displayed in MatLab®.

New features in this release:

  • Integration of FreeImage into MXLib. New functions ImRead() and ImWrite() use the FreeImage library to load and save image files such as .bmp, .jpg, .tiff, etc. Integrates seamlessly with the MXMatrix class and will by default flip the images over and reorder the color channels to match how the data would be structured after loading the image file in MatLab®. Will handle just about anything that FreeImage does except for greyscale images with alpha channels. Includes a prebuilt 64-bit library and DLL for Windows because they sometimes have trouble doing this. Linux developers will have to use/make their own. To learn more about FreeImage, go to:  http://freeimage.sourceforge.com

  • New simple TIC-TOC style timers for Linux and Windows.

  • Some of bug fixes.

What MXLib does not do (or doesn’t do yet):

  • Although MatLab® is not necessary to use MXLib; it does not completely replace MatLab®! MatLab® is a wonderful tool. Use it. Buy it. The MatLab® Compiler is also a good tool for certain projects, but many projects can’t use or don’t want to use it because of performance issues, installed library requirements, code obfuscation issues, etc.

  • It does not automatically generate C++ code like the MatLab® Coder. MatLab® Coder is an interesting product that has its uses, but anyone who has used it knows the kind of code it spits out and how hard that is to modify or integrate with other code.

  • Does not release you from the need to obtain a legitimate copy of IPP. IPP can be used free of charge under Linux for non-commercial use and you can download a demo version for Windows. Please visit the Intel IPP website at: http://software.intel.com/en-us/articles/intel-ipp/#support and be sure to read the any User Agreements and Copyright restrictions there.

  • Does not include precompiled libraries (yet!). For the time being MXLib comes as template class code that is compatible with Linux (GCC and Intel® compilers) and Windows (Tested with Visual Studio 2010 Pro) that is included in your project and compiled each time. It compiles rather quickly with VS 2010, but can be a bit slow to build under Linux especially when using the Intel compiler. This difference is due to how the different compilers handle template class code and is out of my control.

What is Coming Next

  • Support for NVidia's NPP CUDA library!  The code for this will work similarly to the current IPP based code in MXLib and will allow switching between computations on the CPU and on the GPU easy.
  • Things that people suggest.

If you have any questions or suggestions, please contact me here or in the discussions in the Sourceforge project.

Enjoy!

Developer of MXLib - C++ Wrapper for IPP.
https://sourceforge.net/projects/mxlib/
7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Jay,

Could you provide a link to a Tutorial for the library ( online or in pdf-format ) and a small test-case on how these wrappers work. For example, I'd like to see how to add two floating point 32x32 images ( nothing else! ).

Thanks in advance.

The Math eXtension Library.docx in the Documentation folder gives a broad overview of how the library works and the MXLib.cpp in the src folder has a lot of code in it (mostly commented out) that gives examples of how it works.  This is where I do some last-minute testing of the library to make everything works and looks right.  The download also includes VS2010 (Windows) and Eclipse (Linux) example projects.  

Even though I don't know why you'd want do this, a quick example here of how to load 24-bit PNG files, convert the values in to Ipp32f, add them together and save them to a data file for input to MatLab:

MXMatrix<Ipp8u>  m8u, m8u1;
MXMatrix<Ipp32f> m32f, m32f1, m32f2;

 // Load the images
 m8u.ImRead( "nasa_moon.jpg", 0, true, true, true );  
 m8u1.ImRead( "nasa_moon1.jpg", 0, true, true, true );

 // Convert to type Ipp32f
 m32f = m8u;
 m32f1 = m8u1;
        
 // Print the first 5 rows and columns in each channel to the screen with one digit after the decimal point
 m32f( 0, 4, 0, 4).Print( cout, "m32f = ", 1 );
  m32f1( 0, 4, 0, 4).Print( cout, "m32f1 = ", 1 );
        
  // Do some addition
 m32f2 = m32f + m32f1;
 m32f += m32f1;
        
 // Write the results to file that MatLab can read using the included ML functions
 m32f.WriteMxd( "test.mxd" );

I hope this helps.  If you have anymore questions, let me know.

Thanks.

Developer of MXLib - C++ Wrapper for IPP.
https://sourceforge.net/projects/mxlib/

Oopes, make that 2 24-bit JPG files.

Developer of MXLib - C++ Wrapper for IPP.
https://sourceforge.net/projects/mxlib/

>>...
>>// Do some addition
>> m32f2 = m32f + m32f1;
>> m32f += m32f1;
>>...

Thanks and this is exactly what I wanted to see. That is, addition is incapsulated through a C++ operator +.

I'm glad this is what you're looking for.  The emphasis for MXLib is to make it as easy to use as possible for Engineers and Scientists who mostly use MatLab and and don't know or even want to know about the intricacies of C++. Working with IPP in C is also a pain for them. 

The reason I wrote MXLib is that I'm an engineer who has three times now in new jobs has had to make C++ wrappers for IPP so that it's easy to take the MatLab code from our scientist types and port it to C++.  I got tired of doing it over and over again so from now on I can just use MXLib and get straight to work on the stuff that's important.

Developer of MXLib - C++ Wrapper for IPP.
https://sourceforge.net/projects/mxlib/

great job!

Leave a Comment

Please sign in to add a comment. Not a member? Join today