From e1b6271a9588cd276732f90b7c511b48d2f06f5e Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 16 Jan 2019 10:23:18 +0100 Subject: [PATCH] update readme + multithread one test --- README.md | 9 +++++++++ src/tests/op_unit_test.cc | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 80bb18c..786477a 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,15 @@ res2(i1,i2) = res1(i1,i2) / fma(i2,i1) Further examples will follow; you can also look in the test executable source files in `./src/test/*.cc` +# Multithreading + +Multithreading can be enabled by the operation class member function `par()`, which will parallelize the top loop. E.g. for the operation in the example above: +```c++ +/* Enable multithreading for the loop over i1 */ +res1(i1,i2).par() = (ma_a(i1,i2,i4,i5) + ma_b(i4,i3)).c(i4); +``` +Caution: If you want to multithread operations over functional multi arrays, you have to make sure by yourself that involved functors are either static or const (const member variables). + # Planned features Basically the structure of the operation routines allows in some cases (at least in those, where it is possible for simple c++ for loops) vectorization and multi threading. So far the necessary implamentations are not done, but it is planned to enable these features. diff --git a/src/tests/op_unit_test.cc b/src/tests/op_unit_test.cc index a0a8300..72fbe7e 100644 --- a/src/tests/op_unit_test.cc +++ b/src/tests/op_unit_test.cc @@ -457,7 +457,7 @@ namespace { std::cout << "MultiArray time: " << static_cast( end - begin ) / CLOCKS_PER_SEC << std::endl; - res2(delta, deltap) += ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(alpha).c(beta).c(gamma); + res2(delta, deltap).par() += ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(alpha).c(beta).c(gamma); std::vector vres(4*4);