1212#include " oneapi/tbb/task_arena.h"
1313#include " oneapi/tbb/task_group.h"
1414
15- namespace {
16- void MatMul (const std::vector<int > &in_vec, int rc_size, std::vector<int > &out_vec) {
15+ void nesterov_a_test_task_all::MatMul (const std::vector<int > &in_vec, int rc_size, std::vector<int > &out_vec) {
1716 for (int i = 0 ; i < rc_size; ++i) {
1817 for (int j = 0 ; j < rc_size; ++j) {
1918 out_vec[(i * rc_size) + j] = 0 ;
@@ -23,7 +22,17 @@ void MatMul(const std::vector<int> &in_vec, int rc_size, std::vector<int> &out_v
2322 }
2423 }
2524}
26- } // namespace
25+
26+ void nesterov_a_test_task_all::MatMulTBB (const std::vector<int > &in_vec, int rc_size, std::vector<int > &out_vec) {
27+ oneapi::tbb::task_arena arena (1 );
28+ arena.execute ([&] {
29+ tbb::task_group tg;
30+ for (int i = 0 ; i < ppc::util::GetPPCNumThreads (); ++i) {
31+ tg.run ([&] { MatMul (in_vec, rc_size, out_vec); });
32+ }
33+ tg.wait ();
34+ });
35+ }
2736
2837bool nesterov_a_test_task_all::TestTaskALL::ValidationImpl () {
2938 auto sqrt_size = static_cast <int >(std::sqrt (input_.size ()));
@@ -44,17 +53,10 @@ bool nesterov_a_test_task_all::TestTaskALL::RunImpl() {
4453#pragma omp parallel default(none)
4554 {
4655#pragma omp critical
47- { MatMul (input_, rc_size_, output_); }
56+ MatMul (input_, rc_size_, output_);
4857 }
4958 } else {
50- oneapi::tbb::task_arena arena (1 );
51- arena.execute ([&] {
52- tbb::task_group tg;
53- for (int i = 0 ; i < ppc::util::GetPPCNumThreads (); ++i) {
54- tg.run ([&] { MatMul (input_, rc_size_, output_); });
55- }
56- tg.wait ();
57- });
59+ MatMulTBB (input_, rc_size_, output_);
5860 }
5961
6062 const int num_threads = ppc::util::GetPPCNumThreads ();
0 commit comments