locked
How do you use the ScatterGather function? RRS feed

  • Question

  • var resultPort = ScatterGather.Activate(dispatcherQueue, 10, (int i, int num) => num);
    
    
    The above code will fill resultPort with a bunch of zeroes. if I return i instead, it fills up with 0 through 9. This makes sense to me since the i variable is analagous to a for loop variable, and num appears to be some parameter passed in. I get zero since I didn't pass any in.

    var resultPort = ScatterGather.Activate(dispatcherQueue, 10, (int i, int num) => num, 0,1,2,3,4,5,6,7,8,9);
    
    
    I would expect the above code to fill the resultPort.P0 with the numbers 0 through 9, possibly out of order. Instead, I get ten numbers, 0 through 4. For example:
    1
    1
    4
    4
    3
    3
    0
    0
    2
    2

    is my output for one execution. Why is the output not what I expect?
    Thursday, April 23, 2009 6:57 PM

Answers

  • this issue has been fixed (and a similar one for the Iterator overload of the ScatterGather.Activate() method. The parameter array was not properly being processed. The fix also speeds the handling of the scatter significantly.

    Fix will be in next CCR update.

    btw, the scatter gather adapter are fairly simple wrappers on just enqueueing tasks and then using a multiple item receive to collect the results.

    Friday, February 19, 2010 1:38 AM

All replies

  • To clarify, this is from Microsoft.Ccr.Adapters.IO in the CCR/DSS 2008 Toolkit.
    Monday, April 27, 2009 6:48 PM
  • Did you ever figure this out?   It seems like it has to do with the dispatcher, when you change the number of threads it works differently.
    d
    • Proposed as answer by ulab Tuesday, February 2, 2010 9:37 PM
    Tuesday, December 22, 2009 5:48 PM
  • It seems to be a bug, IMHO. As dreadjr suggested, increasing the number of threads fixed it but that is not an acceptable workaround.
    Tuesday, February 2, 2010 10:20 PM
  • var resultPort = ScatterGather.Activate(dispatcherQueue, 10, (int i, int num) => num);
    
    
    
    
    The above code will fill resultPort with a bunch of zeroes. if I return i instead, it fills up with 0 through 9. This makes sense to me since the i variable is analagous to a for loop variable, and num appears to be some parameter passed in. I get zero since I didn't pass any in.

    var resultPort = ScatterGather.Activate(dispatcherQueue, 10, (int i, int num) => num, 0,1,2,3,4,5,6,7,8,9);
    
    
    
    
    I would expect the above code to fill the resultPort.P0 with the numbers 0 through 9, possibly out of order. Instead, I get ten numbers, 0 through 4. For example:
    1
    1
    4
    4
    3
    3
    0
    0
    2
    2

    is my output for one execution. Why is the output not what I expect?

    this appears to be a capture variable issue inside the implementation of scatterGather, Thank you for reporting , we will investigate and have a fix in the next release of the CCR (which is going to be soon, as in a few months)
    Thursday, February 18, 2010 8:41 PM
  • this issue has been fixed (and a similar one for the Iterator overload of the ScatterGather.Activate() method. The parameter array was not properly being processed. The fix also speeds the handling of the scatter significantly.

    Fix will be in next CCR update.

    btw, the scatter gather adapter are fairly simple wrappers on just enqueueing tasks and then using a multiple item receive to collect the results.

    Friday, February 19, 2010 1:38 AM