diff --git a/.github/workflows/doxygenate.yaml b/.github/workflows/doxygenate.yaml index 92c82a9..0fa9541 100644 --- a/.github/workflows/doxygenate.yaml +++ b/.github/workflows/doxygenate.yaml @@ -21,6 +21,11 @@ jobs: with: args: -O docs/tatami.tag https://tatami-inc.github.io/tatami/tatami.tag + - name: Get the manticore tagfile + uses: wei/wget@v1 + with: + args: -O docs/manticore.tag https://tatami-inc.github.io/manticore/manticore.tag + - name: Doxygen Action uses: mattnotmitt/doxygen-action@v1.1.0 with: diff --git a/docs/Doxyfile b/docs/Doxyfile index ebe9d0a..071cd3c 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -2328,7 +2328,8 @@ SKIP_FUNCTION_MACROS = YES # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = tatami.tag=https://tatami-inc.github.io/tatami +TAGFILES = tatami.tag=https://tatami-inc.github.io/tatami \ + manticore.tag=https://tatami-inc.github.io/manticore # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to diff --git a/include/tatami_r/parallelize.hpp b/include/tatami_r/parallelize.hpp index 7015987..ac5599b 100644 --- a/include/tatami_r/parallelize.hpp +++ b/include/tatami_r/parallelize.hpp @@ -40,40 +40,40 @@ inline manticore::Executor& executor() { /** * @tparam Function_ Function to be executed. - * @tparam Index_ Integer type for the job indices. + * @tparam Index_ Integer type for the task indices. * * @param fun Function to run in each thread. * This is a lambda that should accept three arguments: * - Integer containing the thread ID. - * - Integer specifying the index of the first job to be executed in a thread. - * - Integer specifying the number of jobs to be executed in a thread. - * @param njobs Number of jobs to be executed. + * - Integer specifying the index of the first task to be executed in a thread. + * - Integer specifying the number of tasks to be executed in a thread. + * @param ntasks Number of tasks to be executed. * @param nthreads Number of threads to parallelize over. * * This function is a drop-in replacement for `tatami::parallelize()`. - * The series of integers from 0 to `njobs - 1` is split into `nthreads` contiguous ranges. - * Each range is used as input to `fun` within the corresponding thread. - * It is assumed that the execution of any given job is independent of the next. + * The series of integers from `[0, ntasks)` is split into `nthreads` contiguous ranges. + * Each range is used as input to a call to `fun` within a thread created by the standard `` library. + * Serialization can be achieved via `` in most cases, or `manticore::Executor::run()` if the task must be performed on the main thread (see `executor()`). * * This function is only available if `TATAMI_R_PARALLELIZE_UNKNOWN` is defined. */ template -void parallelize(Function_ fun, Index_ njobs, int nthreads) { - if (njobs == 0) { +void parallelize(Function_ fun, Index_ ntasks, int nthreads) { + if (ntasks == 0) { return; } - if (nthreads <= 1 || njobs == 1) { - fun(0, 0, njobs); + if (nthreads <= 1 || ntasks == 1) { + fun(0, 0, ntasks); return; } - Index_ jobs_per_worker = njobs / nthreads; - int remainder = njobs % nthreads; - if (jobs_per_worker == 0) { - jobs_per_worker = 1; + Index_ tasks_per_worker = ntasks / nthreads; + int remainder = ntasks % nthreads; + if (tasks_per_worker == 0) { + tasks_per_worker = 1; remainder = 0; - nthreads = njobs; + nthreads = ntasks; } auto& mexec = executor(); @@ -85,7 +85,7 @@ void parallelize(Function_ fun, Index_ njobs, int nthreads) { Index_ start = 0; for (int w = 0; w < nthreads; ++w) { - Index_ length = jobs_per_worker + (w < remainder); + Index_ length = tasks_per_worker + (w < remainder); runners.emplace_back([&](int id, Index_ s, Index_ l) { try {