Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do concurrent agents support other control-flow patterns besides barriers? #355

Open
Dannnno opened this issue Apr 1, 2017 · 1 comment

Comments

@Dannnno
Copy link

Dannnno commented Apr 1, 2017

For example, OpenMP provides directives like critical, ordered, master, and single. I'm not aware of these (or similar) being provided by the existing concurrent_agent, and they're somewhat hard to do in a portable manner. Is it worthwhile adding these (and potentially others)? And if so, is there any value in having different types of concurrent agents? As an example, there might be an omp::concurrent_agent whose versions of these functions simply take in lambdas and execute them in the appropriate directive, while the default concurrent_agent would have to use an OpenMP independent version of each of them.

@jaredhoberock
Copy link
Collaborator

There may be value in different types of concurrent agents, but only as last resort where no other implementation strategy is possible, I think. The entire purpose of the agent types is to enable portability when writing kernels. For example, the same concurrent_agent type is usable in both CPU and GPU programs.

For the features you mention, maybe it would be possible to implement them externally to concurrent_agent. My guess is that concurrent_agent's barrier is sufficient to implement all of the control structures you mention.

For example, it's possible to implement a critical section using .elect() & .wait():

if(self.elect())
{
  // do critical section stuff
  ...
}
self.wait();

It might be useful to wrap up the implementations of some of the more common control structures into functions, and it would be interesting to investigate any performance differences between pure OpenMP implementations of these directives versus what one could emulate with concurrent_agent. For example, we noted that an ad hoc reduction implemented in Agency happened to out-perform OpenMP's native reduction directive. So it's not clear that native OpenMP directives always imply an efficiency advantage.

Another issue with the OpenMP directives is that the programmer is constrained by where directives are allowed to be used. Some of the directives (like ordered) must be applied to the for loop encapsulating the execution. However, the programmer would request the ordered section at a code location distant from the originating for loop. So my guess is that the way that some of the OpenMP features are requested by directives probably isn't compatible with the way Agency is organized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants