1#ifndef TATAMI_PYTHON_PARALLELIZE_HPP
2#define TATAMI_PYTHON_PARALLELIZE_HPP
7#ifdef TATAMI_PYTHON_PARALLELIZE_UNKNOWN
12#include "pybind11/pybind11.h"
13#include "subpar/subpar.hpp"
17#ifndef TATAMI_PYTHON_SERIALIZE
21#define TATAMI_PYTHON_SERIALIZE ::tatami_python::lock
56template<
class Function_,
class Index_>
57int parallelize(
const Function_ fun,
const Index_ tasks,
int workers) {
58 std::optional<pybind11::gil_scoped_release> ungil;
59 if (PyGILState_Check()) {
62 return subpar::parallelize_range(workers, tasks, std::move(fun));
74template<
typename Function_>
76 std::optional<pybind11::gil_scoped_acquire> gil;
77 if (!PyGILState_Check()) {
tatami bindings for arbitrary Python matrices.
int parallelize(const Function_ fun, const Index_ tasks, int workers)
Definition parallelize.hpp:57
void lock(Function_ fun)
Definition parallelize.hpp:75