syrk.hpp
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief matrix-matrix multiplication kernel for symmetrik Rank-K updates
5  *
6  * \author O. Krause
7  * \date 2016
8  *
9  *
10  * \par Copyright 1995-2015 Shark Development Team
11  *
12  * <BR><HR>
13  * This file is part of Shark.
14  * <http://image.diku.dk/shark/>
15  *
16  * Shark is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Lesser General Public License as published
18  * by the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * Shark is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28  *
29  */
30 
31 #ifndef REMORA_KERNELS_SYRK_HPP
32 #define REMORA_KERNELS_SYRK_HPP
33 
34 #include "default/syrk.hpp"
35 
36 #ifdef REMORA_USE_CBLAS
37 #include "cblas/syrk.hpp"
38 #else
39 //if no bindings are included, we have to provide the default has_optimized_syrk otherwise the binding will take care of this
40 namespace remora{ namespace bindings{
41 template<class M1, class M2>
42 struct has_optimized_syrk
43 : public std::false_type{};
44 }}
45 #endif
46 
47 namespace remora{namespace kernels{
48 
49 ///\brief Well known SYmmetric Rank-K update kernel M+=alpha*A*A^T.
50 ///
51 /// Note that it assumes M to be symmetric and it will only touch the upper or lower triangular area.
52 /// If bindings are included and the matrix combination allow for a specific binding
53 /// to be applied, the binding is called automatically from {binding}/syrk.h
54 /// otherwise default/syrk.h is used.
55 template<bool Upper, class M, class E>
56 void syrk(
57  matrix_expression<E, cpu_tag> const& e,
58  matrix_expression<M, cpu_tag>& m,
59  typename M::value_type alpha
60 ) {
61  REMORA_SIZE_CHECK(m().size1() == m().size2());
62  REMORA_SIZE_CHECK(m().size1() == e().size1());
63 
64  bindings::syrk<Upper>(e, m, alpha,
65  typename bindings::has_optimized_syrk<M,E>::type()
66  );
67 }
68 
69 }}
70 
71 #ifdef REMORA_USE_CLBLAST
72 #include "clBlast/syrk.hpp"
73 #elif REMORA_USE_GPU
74 #include "gpu/syrk.hpp"
75 #endif
76 
77 #endif