Project

General

Profile

Feature #1433

lambda syntax for CkLoop

Added by Jim Phillips over 2 years ago. Updated over 1 year ago.

Status:
Merged
Priority:
Normal
Category:
SMP
Target version:
Start date:
02/17/2017
Due date:
% Done:

0%

Spent time:

Description

Support syntax similar to the following:

CkLoop_Parallelize( numChunks, lowerRange, upperRange,
  [=](int first, int last) {
    for ( int i=first; i<=last; ++i ) {
      ...
    }
  }, sync, redResult, type, [=]() {
    ... optional caller function body ...
  }
);

I altered the order of arguments to keep the loop bounds at the top.

CkLambda.h View (2.53 KB) Jim Phillips, 02/23/2017 07:51 AM

History

#1 Updated by Jim Phillips over 2 years ago

Prototype implementation attached.

Missing reductions (more complex reductions should be supported anyway).

Does implement fall-through for numChunks = 1 (or numChunks = 0 with caller function).

Non-sync isn't implemented, since the lambda is being passed between threads as a std::function<void()>* and there would need to at least be a way to preserve and then destroy the std::function after the CkLoop_Parallelize call exits. Capture by reference of local variables would of course never work.

#2 Updated by Eric Bohm about 2 years ago

  • Assignee set to Kavitha Chandrasekar

#3 Updated by Sam White almost 2 years ago

  • Target version changed from 6.8.1 to 6.9.0

#4 Updated by Kavitha Chandrasekar over 1 year ago

  • Status changed from New to Implemented

https://charm.cs.illinois.edu/gerrit/#/c/3498/

This patch adds Jim's lambda syntax prototype to CkLoop. I will look to add reduction and non-sync support to this.

#5 Updated by Sam White over 1 year ago

  • Status changed from Implemented to Merged

Also available in: Atom PDF