ViennaCL - The Vienna Computing Library: libviennacl/src/blas3_host.cpp Source File

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
blas3_host.cpp
Go to the documentation of this file.
1 /* =========================================================================
2 Copyright (c) 2010-2014, Institute for Microelectronics,
3 Institute for Analysis and Scientific Computing,
4 TU Wien.
5 Portions of this software are copyright by UChicago Argonne, LLC.
6
7 -----------------
8 ViennaCL - The Vienna Computing Library
9 -----------------
10
11 Project Head: Karl Rupp rupp@iue.tuwien.ac.at
12
13 (A list of authors and contributors can be found in the PDF manual)
14
15 License: MIT (X11), see file LICENSE in the base directory
16 ============================================================================= */
17
18 // include necessary system headers
19 #include <iostream>
20
21 #include "viennacl.hpp"
22 #include "viennacl_private.hpp"
23
24 #include "blas3.hpp"
25
26 //include basic scalar and vector types of ViennaCL
27 #include "viennacl/scalar.hpp"
28 #include "viennacl/vector.hpp"
29 #include "viennacl/matrix.hpp"
30 #include "viennacl/linalg/direct_solve.hpp"
31 #include "viennacl/linalg/prod.hpp"
32
33
34 //
35 // xGEMV
36 //
37
38 namespace detail
39 {
40 template <typename NumericT>
41 ViennaCLStatus ViennaCLHostgemm_impl(ViennaCLBackend /*backend*/,
42 ViennaCLOrder orderA, ViennaCLTranspose transA,
43 ViennaCLOrder orderB, ViennaCLTranspose transB,
44 ViennaCLOrder orderC,
45 ViennaCLInt m, ViennaCLInt n, ViennaCLInt k,
46 NumericT alpha,
47 NumericT *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda,
48 NumericT *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb,
49 NumericT beta,
50 NumericT *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
51 {
52 typedef typename viennacl::matrix_base<NumericT>::size_type size_type;
53 typedef typename viennacl::matrix_base<NumericT>::size_type difference_type;
54
55 size_type A_size1 = static_cast<size_type>((transA == ViennaCLTrans) ? k : m);
56 size_type A_size2 = static_cast<size_type>((transA == ViennaCLTrans) ? m : k);
57
58 size_type B_size1 = static_cast<size_type>((transB == ViennaCLTrans) ? n : k);
59 size_type B_size2 = static_cast<size_type>((transB == ViennaCLTrans) ? k : n);
60
61 bool A_row_major = (orderA == ViennaCLRowMajor);
62 bool B_row_major = (orderB == ViennaCLRowMajor);
63 bool C_row_major = (orderC == ViennaCLRowMajor);
64
65 viennacl::matrix_base<NumericT> matA(A, viennacl::MAIN_MEMORY,
66 A_size1, size_type(offA_row), difference_type(incA_row), size_type(A_row_major ? m : lda),
67 A_size2, size_type(offA_col), difference_type(incA_col), size_type(A_row_major ? lda : k), A_row_major);
68
69 viennacl::matrix_base<NumericT> matB(B, viennacl::MAIN_MEMORY,
70 B_size1, size_type(offB_row), difference_type(incB_row), size_type(B_row_major ? k : ldb),
71 B_size2, size_type(offB_col), difference_type(incB_col), size_type(B_row_major ? ldb : n), B_row_major);
72
73 viennacl::matrix_base<NumericT> matC(C, viennacl::MAIN_MEMORY,
74 size_type(m), size_type(offC_row), difference_type(incC_row), size_type(C_row_major ? m : ldc),
75 size_type(n), size_type(offC_col), difference_type(incC_col), size_type(C_row_major ? ldc : n), C_row_major);
76
77 detail::gemm_dispatch(alpha, matA, transA, matB, transB, beta, matC);
78
79 return ViennaCLSuccess;
80 }
81
82 }
83
84
85 VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSgemm(ViennaCLBackend backend,
86 ViennaCLOrder orderA, ViennaCLTranspose transA,
87 ViennaCLOrder orderB, ViennaCLTranspose transB,
88 ViennaCLOrder orderC,
89 ViennaCLInt m, ViennaCLInt n, ViennaCLInt k,
90 float alpha,
91 float *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda,
92 float *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb,
93 float beta,
94 float *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
95 {
96 return detail::ViennaCLHostgemm_impl<float>(backend,
97 orderA, transA,
98 orderB, transB,
99 orderC,
100 m, n, k,
101 alpha,
102 A, offA_row, offA_col, incA_row, incA_col, lda,
103 B, offB_row, offB_col, incB_row, incB_col, ldb,
104 beta,
105 C, offC_row, offC_col, incC_row, incC_col, ldc);
106 }
107
108 VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDgemm(ViennaCLBackend backend,
109 ViennaCLOrder orderA, ViennaCLTranspose transA,
110 ViennaCLOrder orderB, ViennaCLTranspose transB,
111 ViennaCLOrder orderC,
112 ViennaCLInt m, ViennaCLInt n, ViennaCLInt k,
113 double alpha,
114 double *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda,
115 double *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb,
116 double beta,
117 double *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
118 {
119 return detail::ViennaCLHostgemm_impl<double>(backend,
120 orderA, transA,
121 orderB, transB,
122 orderC,
123 m, n, k,
124 alpha,
125 A, offA_row, offA_col, incA_row, incA_col, lda,
126 B, offB_row, offB_col, incB_row, incB_col, ldb,
127 beta,
128 C, offC_row, offC_col, incC_row, incC_col, ldc);
129 }
130
131
ViennaCLTranspose
ViennaCLTranspose
Definition: viennacl.hpp:68
viennacl::matrix_base::size_type
SizeT size_type
Definition: matrix_def.hpp:112
ViennaCLBackend_impl
Generic backend for CUDA, OpenCL, host-based stuff.
Definition: viennacl_private.hpp:54
detail::gemm_dispatch
void gemm_dispatch(ScalarType alpha, MatrixTypeA const &A, ViennaCLTranspose transA, MatrixTypeB const &B, ViennaCLTranspose transB, ScalarType beta, MatrixTypeC &C)
Definition: blas3.hpp:39
prod.hpp
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
matrix.hpp
Implementation of the dense matrix class.
viennacl::matrix_base< NumericT >
ViennaCLStatus
ViennaCLStatus
Definition: viennacl.hpp:97
VIENNACL_EXPORTED_FUNCTION
#define VIENNACL_EXPORTED_FUNCTION
Definition: viennacl.hpp:40
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl_private.hpp
ViennaCLOrder
ViennaCLOrder
Definition: viennacl.hpp:61
ViennaCLHostDgemm
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDgemm(ViennaCLBackend backend, ViennaCLOrder orderA, ViennaCLTranspose transA, ViennaCLOrder orderB, ViennaCLTranspose transB, ViennaCLOrder orderC, ViennaCLInt m, ViennaCLInt n, ViennaCLInt k, double alpha, double *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda, double *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb, double beta, double *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
Definition: blas3_host.cpp:108
ViennaCLInt
int ViennaCLInt
Definition: viennacl.hpp:48
direct_solve.hpp
Implementations of dense direct solvers are found here.
ViennaCLHostSgemm
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSgemm(ViennaCLBackend backend, ViennaCLOrder orderA, ViennaCLTranspose transA, ViennaCLOrder orderB, ViennaCLTranspose transB, ViennaCLOrder orderC, ViennaCLInt m, ViennaCLInt n, ViennaCLInt k, float alpha, float *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda, float *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb, float beta, float *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
Definition: blas3_host.cpp:85
viennacl::MAIN_MEMORY
Definition: forwards.h:348
vector.hpp
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
ViennaCLRowMajor
Definition: viennacl.hpp:64
blas3.hpp
ViennaCLTrans
Definition: viennacl.hpp:72
detail::ViennaCLHostgemm_impl
ViennaCLStatus ViennaCLHostgemm_impl(ViennaCLBackend, ViennaCLOrder orderA, ViennaCLTranspose transA, ViennaCLOrder orderB, ViennaCLTranspose transB, ViennaCLOrder orderC, ViennaCLInt m, ViennaCLInt n, ViennaCLInt k, NumericT alpha, NumericT *A, ViennaCLInt offA_row, ViennaCLInt offA_col, ViennaCLInt incA_row, ViennaCLInt incA_col, ViennaCLInt lda, NumericT *B, ViennaCLInt offB_row, ViennaCLInt offB_col, ViennaCLInt incB_row, ViennaCLInt incB_col, ViennaCLInt ldb, NumericT beta, NumericT *C, ViennaCLInt offC_row, ViennaCLInt offC_col, ViennaCLInt incC_row, ViennaCLInt incC_col, ViennaCLInt ldc)
Definition: blas3_host.cpp:41
scalar.hpp
Implementation of the ViennaCL scalar class.
viennacl.hpp
ViennaCLSuccess
Definition: viennacl.hpp:99