DARMA-tasking-internal / darma-frontend

Header library providing the frontend programming model for the DARMA asynchronous many-task model
Other
7 stars 0 forks source link

allow Functors to explicitly specify their permissions #56

Open dhollman opened 6 years ago

dhollman commented 6 years ago

This would be expressed via required_permissions or permissions_downgrades static methods of the user-defined functor that take the same arguments as the Functor's call operator, except that no automatic dereferencing would occur and static permissions downgrades implied by the parameter's type (e.g., ReadAccessHandle<T>) are not required to match. (The create_concurrent_work analog of this would have some differences; we can put that in a separate issue). For instance,

struct MyFunctor {
  void operator()(AccessHandle<int> a, double& b, ReadAccessHandle<float> c) const;
  static auto permissions_downgrades(
    AccessHandle<int> a, AccessHandle<double> b, AccessHandle<float> c
  );
};

The specification of the two static method options should be mutually exclusive: required_permissions should assume no permissions and add in the returned permissions, while permissions_downgrades should express downgrades of the permissions implied by the call operator parameters.

The required_permissions and permissions_downgrades methods should return, respectively, the result of a call to variadic free function templates named darma::required_permissions and darma::permissions_downgrades (which, in turn, return an unspecified type with shared_ptr-like semantics). These function templates would take the same order-independent arguments as can be given to a lambda-style create_work to express permissions_downgrades (with the extension that we'd have to have some new ones like modifies to express permissions upgrades). Example:

auto MyFunctor::permissions_downgrades(
    AccessHandle<int> a, AccessHandle<double> b, AccessHandle<float> c
) {
  return darma::permissions_downgrades(reads(a), schedule_only(reads(c));
}

Some potential challenges:

dhollman commented 6 years ago

Example usage added in this commit of the darma-examples repository

dhollman commented 6 years ago

@giulioborghesi How likely are you to be able to do this one? Since I'll be focussing on the simple backend for ECP, it would be nice if this were something you could do. The example usage in the apps/jacobi_2d/jacobi_oo directory of the DARMA examples repository should serve as a guide for what needs to work.

giulioborghesi commented 6 years ago

I will have a look at this. I think I should be able to do it