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

add ability to use c++17 parallel algorithms #13

Open
martinjrobins opened this issue Oct 13, 2017 · 2 comments
Open

add ability to use c++17 parallel algorithms #13

martinjrobins opened this issue Oct 13, 2017 · 2 comments

Comments

@martinjrobins
Copy link
Collaborator

v0.5 added ability to use Thrust library for parallel algorithms. This is done in src/detail/Algorithms.h using custom Aboria algorithms, which use tag dispatching to either call Thrust or STL algorithms, depending on if the Level 0 vector is a STL vector or a Thrust vector.

For STL vectors, and if using a c++17, parallel algorithms could be used for all algorithms, this functionality needs to be added (i.e. detect if c++17 available, and use a parallel executor if so)

@praveen-velliengiri
Copy link

@martinjrobins. All algorithms cannot parallelizable. Please provide some more informations.
Thanks
Pree

@martinjrobins
Copy link
Collaborator Author

martinjrobins commented Oct 14, 2017

There are a number of functions/algorithms in src/detail/Algorithms.h that are based on the parallel algorithms in Thrust (https://thrust.github.io/), eg. for_each, gather, scatter_if, inclusive_scan, transform_exclusive_scan. These algorithms are used by Aboria in numerous places, and it is assumed that every algorithm is run in parallel.

Every data structure in Aboria is based on a STL-like vector. The default is to use std::vector, but you can also choose to use thrust::device_vector. Passing a thrust::device_vector to any of the functions in stc/detail/Algorithms.h will call the Thrust equivalent algorithm, passing a std::vector::iterator will call the STL equivalent algorithm, or (if this doesn't exist), an custom implementation of the algorithm.

Naturally, all the Thrust algorithms are already parallelized, I would like do do the same for the STL side. It seems like the easiest way to approach this is to use the new parallel algorithms in c++17, but I am open to alternatives.

(btw. I'm also not happy with the organisation of src/detail/Algorithms.h, everything is just lumped in one file and difficult to find, so any improvements here would also be welcome)

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