75 #define OIIO_PARALLEL_PAROPT
85 size_t minitems = 1024) noexcept
86 : m_maxthreads(maxthreads)
87 , m_splitdir(splitdir)
88 , m_minitems(minitems)
93 :
paropt(maxthreads, splitdir, minitems)
104 : m_maxthreads(maxthreads)
111 :
paropt(po.name, po.maxthreads,
SplitDir(po.splitdir), po.minitems)
124 constexpr
bool singlethread() const noexcept {
return m_maxthreads == 1; }
126 constexpr
int maxthreads() const noexcept {
return m_maxthreads; }
140 constexpr
bool recursive() const noexcept {
return m_recursive; }
147 constexpr
int minitems() const noexcept {
return m_minitems; }
169 int m_maxthreads = 0;
172 size_t m_minitems = 16384;
174 bool m_recursive =
false;
196 std::function<
void(int64_t, int64_t)>&& task,
242 std::function<
void(int32_t, int32_t)>&& task,
247 std::function<
void(int64_t, int64_t)>&& task,
252 std::function<
void(uint32_t, uint32_t)>&& task,
257 std::function<
void(uint64_t, uint64_t)>&& task,
277 int64_t ybegin, int64_t yend, int64_t ychunksize,
278 std::function<
void(int64_t xbeg, int64_t xend,
279 int64_t ybeg, int64_t yend)>&& task,
294 parallel_for_2D(int64_t xbegin, int64_t xend, int64_t ybegin, int64_t yend,
295 std::function<
void(int64_t
x, int64_t
y)>&& task,
300 #if OIIO_VERSION < OIIO_MAKE_VERSION(3, 0, 0)
310 std::function<
void(
int id, int64_t
b, int64_t e)>&& task,
316 std::function<
void(
int id, int64_t
index)>&& task,
322 int64_t xbegin, int64_t xend, int64_t xchunksize, int64_t ybegin,
323 int64_t yend, int64_t ychunksize,
324 std::function<
void(
int id, int64_t, int64_t, int64_t, int64_t)>&& task,
329 parallel_for_2D(int64_t xbegin, int64_t xend, int64_t ybegin, int64_t yend,
330 std::function<
void(
int id, int64_t i, int64_t
j)>&& task,
334 xbegin, xend, 0, ybegin, yend, 0,
335 [&task](
int id, int64_t xb, int64_t xe, int64_t yb, int64_t ye) {
336 for (
auto y = yb;
y < ye; ++
y)
337 for (
auto x = xb;
x < xe; ++
x)
348 template<
class InputIt,
class UnaryFunction>
351 parallel_for_each(InputIt begin, InputIt end, UnaryFunction
f,
354 return std::for_each(begin, end, f);
362 int64_t ybegin, int64_t yend, int64_t ,
363 std::function<
void(
int id, int64_t i, int64_t j)>&& task)
OIIO_UTIL_API void parallel_for_2D(int64_t xbegin, int64_t xend, int64_t ybegin, int64_t yend, std::function< void(int64_t x, int64_t y)> &&task, paropt opt=0)
OIIO_UTIL_API thread_pool * default_thread_pool()
constexpr SplitDir splitdir() const noexcept
paropt & splitdir(SplitDir s) noexcept
paropt(string_view name, int maxthreads=0, SplitDir splitdir=SplitDir::Y, size_t minitems=1024) noexcept
String-related utilities, all in namespace Strutil.
bool singlethread() const
paropt & maxthreads(int m) noexcept
Wrappers and utilities for multithreading.
constexpr int maxthreads() const noexcept
paropt(const parallel_options &po) noexcept
constexpr paropt(ParStrategy strat) noexcept
paropt & recursive(bool r) noexcept
OIIO_UTIL_API void parallel_for(int32_t begin, int32_t end, function_view< void(int32_t)> task, paropt opt=0)
paropt & strategy(ParStrategy s) noexcept
parallel_options(int maxthreads=0, SplitDir splitdir=Split_Y, size_t minitems=16384)
GLuint const GLchar * name
OIIO_UTIL_API void parallel_for_chunked_2D(int64_t xbegin, int64_t xend, int64_t xchunksize, int64_t ybegin, int64_t yend, int64_t ychunksize, std::function< void(int64_t xbeg, int64_t xend, int64_t ybeg, int64_t yend)> &&task, paropt opt=0)
constexpr paropt(int maxthreads=0, SplitDir splitdir=SplitDir::Y, size_t minitems=1024) noexcept
GLboolean GLboolean GLboolean b
constexpr paropt(int maxthreads, ParStrategy strat) noexcept
int size() const
How many threads are in the pool?
paropt & minitems(int m) noexcept
constexpr ParStrategy strategy() const noexcept
constexpr int minitems() const noexcept
constexpr bool singlethread() const noexcept
constexpr bool recursive() const noexcept
OIIO_UTIL_API void parallel_for_chunked(int64_t begin, int64_t end, int64_t chunksize, std::function< void(int64_t, int64_t)> &&task, paropt opt=paropt(0, paropt::SplitDir::Y, 1))
paropt & pool(thread_pool *p) noexcept
parallel_options(string_view name, int maxthreads=0, SplitDir splitdir=Split_Y, size_t minitems=16384)
#define OIIO_NAMESPACE_END
OIIO_UTIL_API void parallel_for_range(int32_t begin, int32_t end, std::function< void(int32_t, int32_t)> &&task, paropt opt=0)
bool is_worker(std::thread::id id) const
thread_pool * pool() const noexcept
#define OIIO_NAMESPACE_BEGIN
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.