Under the current release of Amino library project, we have created three parallelized version of existing patterns from STL. The method signature is very close to the original one:
- Foreach
- Transform
- Accumulate
| Pattern Usage | Computing Kernel |
|---|---|
vector<int> dataV; ThreadPoolExecutor exec; for_each(exec, 2, dataV.begin(), dataV.end(), sum); exec.shutdown(); exec.waitTermination(); | void sum (int n) { result += n; } |
| Pattern Usage | Computing Kernel |
|---|---|
| UnaryFunc<int> uf; vector<int> dataV; int i = 0; for ( ; i } ThreadPoolExecutor exec; // change each elemet to its twice transform(exec, 2, dataV.begin(), dataV.end(), dataV.begin(), uf); exec.shutdown(); exec.waitTermination(); | template<typename ParaType> class UnaryFunc { public: ParaType operator()(ParaType element) { return 2 * element; } }; |
| Pattern Usage | Computing Kernel |
|---|---|
| vector<int> dataV; // Test the function 1 int result = accumulate 2, dataV.begin(), dataV.end()); exec.shutdown(); exec.waitTermination(); | template<typename ParaType> class UnaryFunc { public: ParaType operator()(ParaType element) { return 2 * element; } }; |
Please note these patterns are in pretty early stage. The performance is still ridiculous now. Please let us know your opinion about the API design. And contributions are always welcome!