Skip to content
Snippets Groups Projects

Blocking for partial directions

Merged Markus Holzer requested to merge holzer/pystencils:CPU_Blocking into master
2 unresolved threads

In the current implementation, it was only possible to block for all coordinates. However, for some problems it might make sense to only block one specific direction. This can now be achieved by setting unwanted coordinates to zero.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1307 1315 stop = sp.Min(inner_loop.stop, block_ctr + block_size[coord])
1308 1316 inner_loop.start = block_ctr
1309 1317 inner_loop.stop = stop
1310 return len(coordinates)
1318 return coordinates_taken_into_account
  • So this function returns a magic number that will be consumed by OpenMP's collapse and this will work the right way whatever block size you're specifying here? Shouldn't OpenMP collapse all looks that enclose those blocking loops (not how many loops do not use blocking) and avoid that collapse is applied for coordinates that use blocking. Then, this version wouldn't be correct. Anyways, should OpenMP get this information in a way that is less magical (e.g. directly from blocking dimension).

  • So I think collapse should be applied to the number of blocking loops we have produced because they share the same iteration space as the original loops right? I think this was the way of thinking which got into this function originally.

    I think it makes sense to return the number of blocked coordinates then and I am not sure if it is a good idea to just directly extract that information form the blocking tuple. At the moment coordinates_taken_into_account is only increased if a new outer_loop is really produced. If we just extract the information from the tuple it might be more error prone, right?

  • Right, it returns the number of outer loops not the number of inner loops.

  • So the code for (1,16,1) would produce two inner loops that have only one iteration and the goal of this PR is to drop those loops?

  • Yes, thats correct.

  • Please register or sign in to reply
  • Stephan Seitz assigned to @hoenig and unassigned @seitz

    assigned to @hoenig and unassigned @seitz

  • I'm not really familliar with this code. The changes look ok, though appart from the interference of the return value with OpenMP.

    Edited by Stephan Seitz
  • Stephan Seitz approved this merge request

    approved this merge request

  • Markus Holzer added 1 commit

    added 1 commit

    Compare with previous version

  • @holzer maybe you could also fix the strange typo in constant in LoopOverCoordinate with this PR. BlOCK_LOOP_COUNTER_NAME_PREFIX = "_blockctr". It's nearly all uppercase...

  • I don't know exactly which typo you mean? How would you rename it?

  • In astnodes.py BlOCK_LOOP_COUNTER_NAME_PREFIX -> BLOCK_LOOP_COUNTER_NAME_PREFIX

  • The typo hides a bit :smile:

  • Markus Holzer added 1 commit

    added 1 commit

    Compare with previous version

  • Yes this was somehow really hard to see for me. Thanks for the hint!

  • 404 404
    405 405 class LoopOverCoordinate(Node):
    406 406 LOOP_COUNTER_NAME_PREFIX = "ctr"
    407 BlOCK_LOOP_COUNTER_NAME_PREFIX = "_blockctr"
    407 BLOCK_LOOP_COUNTER_NAME_PREFIX = "_blockctr"
  • Markus Holzer added 1 commit

    added 1 commit

    Compare with previous version

  • merged

  • Markus Holzer mentioned in commit facd3ab4

    mentioned in commit facd3ab4

  • Please register or sign in to reply
    Loading