.. index:: pair: class; gpr::linalg::TilePool .. _doxid-classgpr_1_1linalg_1_1_tile_pool: class gpr::linalg::TilePool =========================== .. toctree:: :hidden: Overview ~~~~~~~~ Runs fn(0) .. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class TilePool { public: // construction :target:`TilePool`(const TilePool&); :target:`~TilePool`(); // methods static :ref:`TilePool`& :target:`instance`(); template void :target:`run`(long count, F&& fn); template void :ref:`runWith`(int threads, long count, F&& fn); template void :ref:`start`(long count, F&& fn); void :ref:`finish`(); :ref:`TilePool`& :target:`operator=`(const :ref:`TilePool`&); }; .. _details-classgpr_1_1linalg_1_1_tile_pool: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Runs fn(0) .. fn(count - 1) on the calling thread and a small pool of workers. Items are claimed from a shared counter, so the item-to-thread assignment varies between runs; the callers pass items that write disjoint output and run each item's arithmetic on one thread, which makes the result independent of the thread count. Called from a worker, or with one thread configured, the items run in order on the calling thread. Methods ------- .. index:: pair: function; runWith .. _doxid-classgpr_1_1linalg_1_1_tile_pool_1a4353ce22d30af04afd09cb9319b344ca: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void runWith(int threads, long count, F&& fn) :ref:`run() ` with an explicit thread count in place of the configured one. .. index:: pair: function; start .. _doxid-classgpr_1_1linalg_1_1_tile_pool_1a079040c225509f951f3edaa8066a6f80: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void start(long count, F&& fn) Starts fn(0) .. fn(count - 1) on the workers and returns at once; the calling thread joins with :ref:`finish() `, which runs the items no worker has claimed and waits for the rest. Between the two calls, loops started by the calling thread run serially on it, which leaves it free for communication and for work the items do not touch. fn must stay valid until :ref:`finish() ` returns. With one thread configured, or from inside a worker, every item runs in :ref:`finish() `. .. index:: pair: function; finish .. _doxid-classgpr_1_1linalg_1_1_tile_pool_1a2b20e9776318b5e9f96d2ed3e917bb79: .. ref-code-block:: cpp :class: doxyrest-title-code-block void finish() Joins the items of :ref:`start() `; see there.