英特尔tbb::parallel_for_each编译时错误

Intel tbb::parallel_for_each compile time error

本文关键字:编译时错误 each for parallel tbb 英特尔      更新时间:2023-10-16

我使用parallel_for_each并行化for循环(在stl列表中迭代),但我在编译时遇到错误,说没有匹配的函数调用。

//TBB headers
#include "tbb/parallel_for_each.h"
class FUNCTOR
{
public:
    FUNCTOR(    
        CLASS_A& tree,
        CLASS_B *groups,
        const CLASS_C** default_dominator,
        const CLASS_D& filter
    ):
        tree(tree),
        groups(groups),
        default_dominator(default_dominator),
        filter(filter)
    {}
            // Iterator dereferences to a pointer
    void operator()(const ELEMENT_OF_LIST_A*& keeper) const
    {
        /*something*/
    }
private:
    CLASS_A& tree;
    CLASS_B *groups;
    const CLASS_C** default_dominator;
    const CLASS_D& filter;
};

void some_function
(
    CLASS_A& tree,
    CLASS_B *groups,
    const CLASS_C** default_dominator,
    const LIST_A& keepers,
    const CLASS_D& filter
)
{
    // Some code that claims processors
    //LIST_A_ITER begin = keepers.begin();
    //LIST_A_ITER end = keepers.end();
    //const ELEMENT_OF_LIST_A* keeper = *begin
    tbb::parallel_for_each
    (
        keepers.begin(), keepers.end(),
        FUNCTOR(    
            tree,
            groups,
            default_dominator,
            filter
        )
    );
}

我得到的错误是:

error: no matching function for call to 'tbb::internal::parallel_do_operator_selector<tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>::call(const tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>&, ELEMENT_OF_LIST_A*, tbb::internal::do_iteration_task_iter<LIST_A_ITER, tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>::feeder_type&)'

note: candidate is: static void tbb::internal::parallel_do_operator_selector<Body, Item>::call(const Body&, A1&, A2&) [with A1 = ELEMENT_OF_LIST_A*, A2 = tbb::internal::parallel_do_feeder_impl<tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>, Body = tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, Item = ELEMENT_OF_LIST_A*]

出了什么问题?

谢谢!

FUNCTOR的运算符()具有额外的间接级别。声明时不带*,例如:

const ELEMENT_OF_LIST_A& keeper