jeudi 23 avril 2015

How to parallel variadic function with TBB?

I have a template variadic function like this that need to parallelize with TBB parallel_for function

template<typename T1, typename T2, typename... T3>
void func(T1 t1, T2 t2, T3... t3)

I first tried to use lambda function, it is able to catch the variadic arguments. It compiled with clang using C++11 feature. However, the cluster I use don't have a compiler to support this feature. I have to write a class and pass it to parallel_for function. I tried:

template<typename T1, typename T2, typename... T3>
class ApplyFunc{
     ApplyFunc(T1 t1, T2 t2, T3... t3){
         t1_ = t1;
         t2_ = t2;
         t3_ = t3...;

     }
      void operator(...skip...){
       ...skip...
      }
      private:
         T1 t1_;
         T2 t2_;
         T3... t3_;
}

apparently, variadic variable is not supported. I tried std::tuple t3_; However, I am not able to convert std::tuple<T3...> back into variadic arguments.

Aucun commentaire:

Enregistrer un commentaire