InfiniTAM icon indicating copy to clipboard operation
InfiniTAM copied to clipboard

Resolve thread-blocking in new FillBlocksFunctor CPU version

Open Algomorph opened this issue 4 years ago • 0 comments

In the old InfiniTAM code, the CPU version here was serial, since there was no simple way to atomically modify the pixel ray bound data, the way it's done in the CUDA version using CUDA atomic operations. The only way to use the common traversal functions was to make it an omp critical section. However, this is probably even less efficient than the single-threaded CPU solution due to thread locks.

There are two options:

  1. (Incomplete) Use threadpools to alter the way CPU parallel traversals are done and a provide a mechanism for alternating execution policies for CPU/GPU versions. This way, the CPU version can be made single-threaded via the threadpool. Note: there's no way to do it using OpenMP without severe DRY violations (two versions of identical traversal functions, just one with the omp pragma and one without).

  2. (More complete, harder) Figure out some kind of schema for Images of type Vector2<std::atomic> and use that on the CPU. Not sure how efficient that will be but I have hopes. The solution could involve, for example, converting the Image from regular Vector2 to Vector2<std::atomic> and back. Alternatively, the latter type could be used for the CPU version in all cases from the get-go somehow. Not sure what is better.

Algomorph avatar Jun 01 '20 19:06 Algomorph