continue_node to count messages from single predecessor

continue_node to count messages from single predecessor

Igor的头像

I'm trying to make a counting_node out of the continue_node.

I'm not sure I understand the documentation of the continue_node regaring the value of the internal threshold, T. If I provide a value in constructor, would it still be incremented as I add a predecessor? Also, is it okay to want to have T=2 and only one predecessor? For example, in the code below what is the value of T?

continue_node<continue_msg> count2(g, 1, MessageForward());
make_edge(some_message_generator, count2);
T==2?

Also, is there a predefined simple message forwarder body as follows?

class MessageForward {
    continue_msg operator()(continue_msg /*m*/) {
        return continue_msg();
    }
};

Thanks,
Igor

3 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Christopher Huson (Intel)的头像

Hello, Igor,

Sorry I didn't respond earlier.  Yes, I've also noticed the documentation should be improved.  The continue_node's internal threshold tells how many continue_msg()s are received before the body of the node is executed, but the node doesn't care which predecessors send it a message.  The threshold is incremented when edge is added from a predecessor, and decremented when an edge is removed.

So if you specify 1 as the initial value for the threshold (somewhat misleadingly-named number_of_predecessors), then add one edge from another node to the continue_node, the node will execute its body after every second continue_msg() received.

If the number_of_predecessors is 0, and you add edges from two nodes to the continue_node, after receiving two continue_msg()s from either of the nodes (in any combination) the continue_node will execute its body and attempt to forward the message.  It doesn't require the messages to come from any particular node.

There is no predefined body for the continue_node.

Best Regards,
Chris

Igor的头像

Thank you Chris, continue_node works as you described. This way I can decimate the messages flowing through the graph.

Igor

登陆并发表评论。