1 | /******************************************************************************* |
2 | * Copyright 2022 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 UTILS_PARALLEL_HPP |
18 | #define UTILS_PARALLEL_HPP |
19 | |
20 | #include <cstdint> |
21 | #include <functional> |
22 | |
23 | // `benchdnn_parallel_nd` wrapper is essential for threadpool configuration |
24 | // since testing infrastructure contains a single threadpool object but obliges |
25 | // to differentiate is as two different - one for the library which is activated |
26 | // through the stream object and the other one is for internal library funtions |
27 | // used in tests such as `parallel_nd`. Threadpool for internal needs is |
28 | // referred as `scoped_threadpool` and its activation/deactivation is under test |
29 | // control. This is needed since each primitive execute call will activate the |
30 | // threadpool object passed to the library (which is supposed to be different |
31 | // from the "scoped") and if "scoped" threadpool will be left activated, it will |
32 | // cause an error while trying to activate already activated threadpool. |
33 | |
34 | void benchdnn_parallel_nd(int64_t D0, const std::function<void(int64_t)> &f); |
35 | void benchdnn_parallel_nd( |
36 | int64_t D0, int64_t D1, const std::function<void(int64_t, int64_t)> &f); |
37 | void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, |
38 | const std::function<void(int64_t, int64_t, int64_t)> &f); |
39 | void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, int64_t D3, |
40 | const std::function<void(int64_t, int64_t, int64_t, int64_t)> &f); |
41 | void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, int64_t D3, |
42 | int64_t D4, |
43 | const std::function<void(int64_t, int64_t, int64_t, int64_t, int64_t)> |
44 | &f); |
45 | void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, int64_t D3, |
46 | int64_t D4, int64_t D5, |
47 | const std::function<void( |
48 | int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)> &f); |
49 | |
50 | #endif |
51 | |