Debian Codegraph @

src/atlas/linalg/dense/MatrixMultiply_EckitLinalg.cc

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 /*
12 * (C) Copyright 2013 ECMWF.
13 *
14 * This software is licensed under the terms of the Apache Licence Version 2.0
15 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
16 * In applying this licence, ECMWF does not waive the privileges and immunities
17 * granted to it by virtue of its status as an intergovernmental organisation
18 * nor does it submit to any jurisdiction.
19 */
20
21 #include "MatrixMultiply_EckitLinalg.h"
22
23 #include "atlas/library/config.h"
24 #if ATLAS_ECKIT_HAVE_ECKIT_585
25 #include "eckit/linalg/LinearAlgebraDense.h"
26 #else
27 #include "eckit/linalg/LinearAlgebra.h"
28 #endif
29
30 #include "eckit/linalg/Matrix.h"
31 #include "eckit/linalg/Vector.h"
32
33 #include "atlas/runtime/Exception.h"
34
35 namespace atlas {
36 namespace linalg {
37 namespace dense {
38
39 namespace {
40 #if ATLAS_ECKIT_HAVE_ECKIT_585
41 const eckit::linalg::LinearAlgebraDense& eckit_linalg_backend(const Configuration& config) {
42 std::string backend = "default";
43 config.get("backend", backend);
44 if (backend == "default") {
45 return eckit::linalg::LinearAlgebraDense::backend();
46 }
47 ATLAS_ASSERT(eckit::linalg::LinearAlgebraDense::hasBackend(backend));
48 return eckit::linalg::LinearAlgebraDense::getBackend(backend);
49 }
50 #else
51 const eckit::linalg::LinearAlgebra& eckit_linalg_backend(const Configuration& config) {
52 std::string backend = "default";
53 config.get("backend", backend);
54 if (backend == "default") {
55 return eckit::linalg::LinearAlgebra::backend();
56 }
57 ATLAS_ASSERT(eckit::linalg::LinearAlgebra::hasBackend(backend));
58 return eckit::linalg::LinearAlgebra::getBackend(backend);
59 }
60 #endif
61
62 } // namespace
63
64 void MatrixMultiply<backend::eckit_linalg>::apply(const Matrix& A, const Matrix& B, Matrix& C,
65 const Configuration& config) {
66 eckit_linalg_backend(config).gemm(A, B, C);
67 }
68
69
70 } // namespace dense
71 } // namespace linalg
72 } // namespace atlas