Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Intel IPP and TBB used together

Mohammad_M_1
Beginner
300 Views

I'd like to know how you can use TBB instructions to implement the loop in the following piece of code.The code uses an ipp function and I'd like to be able to use the ipp function with TBB.

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

#include "tbb/task_scheduler_init.h"
#include "tbb/parallel_for.h"
#include "tbb/blocked_range.h"
#include "tbb/tick_count.h"

using namespace tbb;
using namespace std;

#define SIZE 255
#define N 10

int main(int argc, CHAR* argv[])
{
    Ipp8u pSrc[SIZE], pDst[SIZE];
    int i;
    for (int i = 0; i<SIZE ; i++){
        pSrc = (Ipp8u) i;
    }
    for (size_t i = 0; i<N; i++){
        ippsCopy_8u(pSrc,pDst,SIZE); // This is the loop that needs to be implemented in TBB.
    }
    return 0;
}

I have written the following class to implement the parallel_for. But I still need to know how the structure of the parallel_for would be.

class copyVectors{
    Ipp8u *s;
    Ipp8u *d;
public:
    copyVectors(Ipp8u *pSrc, Ipp8u *pDst){
        s = pSrc;
        d = pDst;
    }

    void operator () (const blocked_range<size_t> &r) const {
        ippsCopy_8u(s, d, SIZE);
    }
}

Any help would be highly appreciated.

http://software.intel.com/en-us/forums/intel-threading-building-blocks/

0 Kudos
2 Replies
SergeyKostrov
Valued Contributor II
300 Views
Hi everybody, Mohammad, Here are a couple of notes related to integration of IPP with TBB: 1. What IPP version are you using? 2. Take into account that many functions in a Signal Processing domain of IPP library are threaded ( using OpenMP / the same applies to all the rest domains of IPP ) and it doesn't make sence to create another layer of threading 3. Vectors with lengths of 255 unsigned bytes are too small and overhead of creating new threads will affect performance of your processing 4. There is a good thing because IPP team is considering a new release of IPP library ( version 7, or so ) without multithreading. In that case all your efforts will be paid off 5. Many IPP functions in IPP library version 7 are heavily optimized for CPUs with AVX & AVX2 instructions Also, take a look at a thread: Forum topic: Using Intel TBB with IPP Web-link: http://software.intel.com/en-us/forums/topic/277266 Best regards, Sergey
0 Kudos
SergeyKostrov
Valued Contributor II
300 Views
>>... >>5. Many IPP functions in IPP library version 7 are heavily optimized for CPUs with AVX & AVX2 instructions Take a look at article: . http://software.intel.com/en-us/articles/haswell-support-in-intel-ipp and 'ippsCopy_8u' is listed in a 'Signal Processing' section. Another article to look at is: . https://secure-software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-functions-optimized-for-intel-advanced
0 Kudos
Reply