11/* ******************************************************************************
2- * Copyright 2022-2023 Intel Corporation
2+ * Copyright 2022-2025 Intel Corporation
33*
44* Licensed under the Apache License, Version 2.0 (the "License");
55* you may not use this file except in compliance with the License.
2525#define ACTIVATE_THREADPOOL
2626#endif
2727
28+ void synchronize () {
29+ #if DNNL_CPU_THREADING_RUNTIME == DNNL_RUNTIME_THREADPOOL
30+ dnnl::testing::get_threadpool ()->wait ();
31+ #endif
32+ }
33+
2834// Note: no need in deactivation as `scoped_activation` object will deactivate
2935// it automatically at destruction.
30-
3136void benchdnn_parallel_nd (int64_t D0, const std::function<void (int64_t )> &f) {
3237 ACTIVATE_THREADPOOL;
3338 dnnl::impl::parallel_nd (D0, f);
39+ synchronize ();
3440}
3541
3642void benchdnn_parallel_nd (int64_t D0, int64_t D1,
3743 const std::function<void (int64_t , int64_t )> &f) {
3844 ACTIVATE_THREADPOOL;
3945 dnnl::impl::parallel_nd (D0, D1, f);
46+ synchronize ();
4047}
4148
4249void benchdnn_parallel_nd (int64_t D0, int64_t D1, int64_t D2,
4350 const std::function<void (int64_t , int64_t , int64_t )> &f) {
4451 ACTIVATE_THREADPOOL;
4552 dnnl::impl::parallel_nd (D0, D1, D2, f);
53+ synchronize ();
4654}
4755
4856void benchdnn_parallel_nd (int64_t D0, int64_t D1, int64_t D2, int64_t D3,
4957 const std::function<void (int64_t , int64_t , int64_t , int64_t )> &f) {
5058 ACTIVATE_THREADPOOL;
5159 dnnl::impl::parallel_nd (D0, D1, D2, D3, f);
60+ synchronize ();
5261}
5362
5463void benchdnn_parallel_nd (int64_t D0, int64_t D1, int64_t D2, int64_t D3,
@@ -57,6 +66,7 @@ void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, int64_t D3,
5766 &f) {
5867 ACTIVATE_THREADPOOL;
5968 dnnl::impl::parallel_nd (D0, D1, D2, D3, D4, f);
69+ synchronize ();
6070}
6171
6272void benchdnn_parallel_nd (int64_t D0, int64_t D1, int64_t D2, int64_t D3,
@@ -65,6 +75,7 @@ void benchdnn_parallel_nd(int64_t D0, int64_t D1, int64_t D2, int64_t D3,
6575 int64_t , int64_t , int64_t , int64_t , int64_t , int64_t )> &f) {
6676 ACTIVATE_THREADPOOL;
6777 dnnl::impl::parallel_nd (D0, D1, D2, D3, D4, D5, f);
78+ synchronize ();
6879}
6980
7081int benchdnn_get_max_threads () {
0 commit comments