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
49template<
class Function_,
class Index_>
50void parallelize(
const Function_ fun,
const Index_ tasks,
int threads) {
51 std::optional<pybind11::gil_scoped_release> ungil;
52 if (PyGILState_Check()) {
55 subpar::parallelize_range(threads, tasks, std::move(fun));
67template<
typename Function_>
69 std::optional<pybind11::gil_scoped_acquire> gil;
70 if (!PyGILState_Check()) {
tatami bindings for arbitrary Python matrices.
void parallelize(const Function_ fun, const Index_ tasks, int threads)
Definition parallelize.hpp:50
void lock(Function_ fun)
Definition parallelize.hpp:68