doyubkim / fluid-engine-dev

Fluid simulation engine for computer graphics applications
https://fluidenginedevelopment.org/
MIT License
1.88k stars 263 forks source link

Support HPX multiple tasking system #282

Closed utilForever closed 4 years ago

utilForever commented 4 years ago

I'll add HPX multiple tasking system such as Intel TBB and OpenMP. HPX is the C++ Standard Library for Parallelism and Concurrency(https://github.com/STEllAR-GROUP/hpx).

doyubkim commented 4 years ago

What would be the advantage of using HPX over TBB or OpenMP?

utilForever commented 4 years ago

Refer to utilForever/CubbyFlow-v1#281.

doyubkim commented 4 years ago

I’m getting 500 error. Maybe I don’t have a permission?

utilForever commented 4 years ago

I think it is Github error. I’m getting 500 error, too. 😭

utilForever commented 4 years ago

@doyubkim A link is fixed. 😄

doyubkim commented 4 years ago

Hmm still no access. Do you mind just summarizing the gist of the PR? Was it a perf reason or an API design issue?

utilForever commented 4 years ago
Implemented HPX backend for

future - async
ParallelSort
ParallelFor
ParallelFill
Performance is overall a little bit less than TBB.
Some benchmarks appear far worse than TBB which is actually because I couldn't implement a HPX backend for those. They are actually running on C++11 Threads.

Because the form of the current API, some features such as ParallelRangeFor, ParallelReduce are hard to implement efficiently using HPX.
HPX mostly resembles the STL API. Thus instead of receiving index ids, it expects iterators for most of the time.

Future proposals

A change in the API for ParallelRangeFor, ParallelReduce.
I suggest to change the index parameters to iterators.
This will require to change all the algorithm function calls too.

Implementation of a global thread pool (or task queue)
This way the C++11 implementation could become much simpler.
And there will be less overhead since we don't create threads each time of running a parallel algorithm.
utilForever commented 4 years ago

I'll implement these 4 functions first and rest after it is merged.

doyubkim commented 4 years ago

We already have TBB as an optional backend. Not sure why another backend is necessary? Did you test HPX backend with TBB backend? Also, I’d rather avoid breaking changes in public API.

utilForever commented 4 years ago

I proposed for library diversity, but your opinion makes sense. I agree with you and will try to close this issue.