oneAPI Deep Neural Network Library (oneDNN)
Performance library for Deep Learning
2.1.3
dnnl_threadpool_iface.hpp
1/*******************************************************************************
2* Copyright 2020 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
17#ifndef ONEAPI_DNNL_DNNL_THREADPOOL_IFACE_HPP
18#define ONEAPI_DNNL_DNNL_THREADPOOL_IFACE_HPP
19
20#include <functional>
21
24
25namespace dnnl {
26
29
32
33namespace threadpool_interop {
34
40 virtual int get_num_threads() const = 0;
41
43 virtual bool get_in_parallel() const = 0;
44
49 virtual void parallel_for(int n, const std::function<void(int, int)> &fn)
50 = 0;
51
53 virtual uint64_t get_flags() const = 0;
54
57 static constexpr uint64_t ASYNCHRONOUS = 1;
58
59 virtual ~threadpool_iface() {}
60};
61
62} // namespace threadpool_interop
63
65
67
68} // namespace dnnl
69
71
72#endif
oneDNN namespace
Definition: dnnl.hpp:74
Abstract threadpool interface.
Definition: dnnl_threadpool_iface.hpp:38
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 uint64_t get_flags() const =0
Returns threadpool behavior flags bit mask (see below).
static constexpr uint64_t ASYNCHRONOUS
If set, parallel_for() returns immediately and oneDNN needs implement waiting for the submitted closu...
Definition: dnnl_threadpool_iface.hpp:57
virtual void parallel_for(int n, const std::function< void(int, int)> &fn)=0
Submits n instances of a closure for execution in parallel: