GithubHelp home page GithubHelp logo

Comments (8)

daviditen avatar daviditen commented on May 18, 2024

I've been working with @abhi-rao on this. I think it's nearly ready, but we need to choose a name that works for everybody. It is currently named iter roundRobinBasedChunkOfBlocks(r: range, blockSize, idx, numChunks) in PR #5928.

from chapel.

daviditen avatar daviditen commented on May 18, 2024

Maybe: blockCyclicChunks(r: range, blockSize, idx, numInds)

Some possible names for the last two arguments:

(tid, numTasks) // The names from the first comment in this issue
(rank, numRanks)
(idx, numInds)

from chapel.

psahabu avatar psahabu commented on May 18, 2024

Even though it takes a second for me to get what is meant by idx, (idx, numInds) fits best with the rest of the library so I support that choice.

from chapel.

rahulghangas avatar rahulghangas commented on May 18, 2024

Here's something I whipped up quickly (would be written properly later) if this is still not implemented (it looks like it hasn't been in RangeChunk.chpl). Ignore the mix of snake and camel case

--EDIT--
There was an off by one bug

iter rr(r, blockSize, idx, numInds){
  
  var range_stride = r.stride;
  var block_stride = blockSize * range_stride;
  var low = r.low;
  var high = r.high;
  var first_block_start = (if range_stride > 0 then r.low  else r.high) + block_stride * idx;
  if first_block_start > r.high || first_block_start < r.low then return;

  var stride_to_next_block = block_stride * numInds;
  
  if range_stride > 0 {
    for block_start in first_block_start..high by stride_to_next_block {
      var block_end = min(high, block_start + block_stride - 1);
      yield block_start..block_end by range_stride;
    }
  }else{
    for block_end in low..first_block_start by stride_to_next_block {
      var block_start = max(low, block_end + block_stride + 1);
      yield block_start..block_end by abs(range_stride);
    }
  }
}

writeln("1: ", rr(1..100, 3, 3, 5));
writeln("2: ", rr(-7..25, 3, 3, 5));
writeln("3: ", rr(25..50, 3, 3, 5));
writeln("4: ", rr(0..99 by 2, 3, 3, 5));
writeln("5: ", rr(1..100 by 3, 3, 3, 5));
writeln("6: ", rr(3..30 by -2, 3, 3, 5));
writeln("7: ", rr(0..1 by -1, 1, 0, 2));

Outputs

1: 10..12 25..27 40..42 55..57 70..72 85..87 100..100
2: 2..4 17..19
3: 34..36 49..50
4: 18..23 by 2 48..53 by 2 78..83 by 2
5: 28..36 by 3 73..81 by 3
6: 7..12 by 2
7: 1..1

from chapel.

rahulghangas avatar rahulghangas commented on May 18, 2024

@daviditen should I open a new PR since the old one has been stagnant for a while?

from chapel.

daviditen avatar daviditen commented on May 18, 2024

@rahulghangas Yes, sounds good. Thanks!

from chapel.

cassella avatar cassella commented on May 18, 2024

Did #15109 fully implement the request here?

from chapel.

daviditen avatar daviditen commented on May 18, 2024

Yes, I think so. Thanks!

from chapel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.