Developer Guide and Reference

  • 2022.1
  • 04/11/2022
  • Public Content

struct dnnl::threadpool_interop::threadpool_iface


Abstract threadpool interface. More…
#include <dnnl_threadpool_iface.hpp> struct threadpool_iface { // fields static constexpr uint64_t ASYNCHRONOUS = 1; // methods virtual int get_num_threads() const = 0; virtual bool get_in_parallel() const = 0; virtual void parallel_for(int n, const std::function<void(int, int)>& fn) = 0; virtual uint64_t get_flags() const = 0; };

Detailed Documentation

Abstract threadpool interface.
The users are expected to subclass this interface and pass an object to the library during CPU stream creation or directly in case of BLAS functions.
static constexpr uint64_t ASYNCHRONOUS = 1
If set, parallel_for() returns immediately and oneDNN needs implement waiting for the submitted closures to finish execution on its own.
virtual int get_num_threads() const = 0
Returns the number of worker threads.
virtual bool get_in_parallel() const = 0
Returns true if the calling thread belongs to this threadpool.
virtual void parallel_for(int n, const std::function<void(int, int)>& fn) = 0
Submits n instances of a closure for execution in parallel:
for (int i = 0; i < n; i++) fn(i, n);
virtual uint64_t get_flags() const = 0
Returns threadpool behavior flags bit mask (see below).

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at