29 lines
		
	
	
		
			852 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			852 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // 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 = MatrixXf::Random(n, n);
 | |
|   MatrixXf b = MatrixXf::Random(n, n);
 | |
|   MatrixXf c = MatrixXf::Random(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()); }
 | 
