mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Generalize parallel GEMM implementation in Core to work with ThreadPool in addition to OpenMP.
This commit is contained in:
33
test/product_threaded.cpp
Normal file
33
test/product_threaded.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2023 Rasmus Munk Larsen <rmlarsen@google.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#define EIGEN_GEMM_THREADPOOL
|
||||
#include "main.h"
|
||||
|
||||
void test_parallelize_gemm() {
|
||||
constexpr int n = 1024;
|
||||
constexpr int num_threads = 4;
|
||||
MatrixXf a(n,n);
|
||||
MatrixXf b(n,n);
|
||||
MatrixXf c(n,n);
|
||||
c.noalias() = a*b;
|
||||
|
||||
ThreadPool pool(num_threads);
|
||||
MatrixXf c_threaded(n,n);
|
||||
c_threaded.noalias() = a*b;
|
||||
|
||||
VERIFY_IS_APPROX(c, c_threaded);
|
||||
}
|
||||
|
||||
|
||||
|
||||
EIGEN_DECLARE_TEST(product_threaded)
|
||||
{
|
||||
CALL_SUBTEST(test_parallelize_gemm());
|
||||
}
|
||||
Reference in New Issue
Block a user