blitz Version 1.0.2
Loading...
Searching...
No Matches
tmevaluate.h
Go to the documentation of this file.
1/***************************************************************************
2 * blitz/tinyvec.cc Declaration of TinyVector methods
3 *
4 * $Id$
5 *
6 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
7 *
8 * This file is a part of Blitz.
9 *
10 * Blitz is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation, either version 3
13 * of the License, or (at your option) any later version.
14 *
15 * Blitz is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * Suggestions: blitz-devel@lists.sourceforge.net
24 * Bugs: blitz-support@lists.sourceforge.net
25 *
26 * For more information, please see the Blitz++ Home Page:
27 * https://sourceforge.net/projects/blitz/
28 *
29 ***************************************************************************/
30
31#ifndef BZ_TMEVALUATE_H
32#define BZ_TMEVALUATE_H
33
34#include <blitz/tinymat2.h>
35#include <blitz/update.h>
36#include <blitz/blitz.h>
37#include <blitz/meta/vecassign.h>
38
39namespace blitz {
40
41
44template<bool unroll, int N_rows, int N_columns>
46
55 template<typename T, typename T_expr, typename T_update>
56 static _bz_forceinline void
58 const T_expr& expr, T_update) {
59
60 // since we can't resize tinyvectors, there are two options: all
61 // vectors have our size or the expression is malformed.
62 // Check that all operands have the same shape
63#ifdef BZ_DEBUG
64 if (!expr.shapeCheck(dest.shape()))
65 {
66 if (assertFailMode == false)
67 {
68 cerr << "[Blitz++] Shape check failed: Module " << __FILE__
69 << " line " << __LINE__ << endl
70 << " Expression: ";
71 prettyPrintFormat format(true); // Use terse formatting
72 std::string str;
73 expr.prettyPrint(str, format);
74 cerr << str << endl ;
75 }
76 }
77#endif
78
79 BZPRECHECK(expr.shapeCheck(dest.shape()),
80 "Shape check failed." << endl << "Expression:");
81
82 // now call the aligned (unrolled or not) evaluation function
85 }
86
91 template<typename T_numtype, typename T_expr, typename T_update>
92 static _bz_forceinline void
93 evaluate_aligned(T_numtype* data, const T_expr& expr, T_update) {
94#ifdef BZ_USE_ALIGNMENT_PRAGMAS
95#pragma ivdep
96#pragma vector aligned
97#endif
98 for (int i=0; i < N_rows*N_columns; ++i)
99 T_update::update(data[i], expr.fastRead(i));
100 }
101
106 template<typename T_numtype, typename T_expr, typename T_update>
107 static _bz_forceinline void
108 evaluate_unaligned(T_numtype* data, const T_expr& expr, T_update) {
109#ifdef BZ_USE_ALIGNMENT_PRAGMAS
110#pragma ivdep
111#pragma vector unaligned
112#endif
113 for (int i=0; i < N_rows*N_columns; ++i)
114 T_update::update(data[i], expr.fastRead(i));
115 }
116};
117
119template<int N_rows, int N_columns>
121
125 template<typename T, typename T_expr, typename T_update>
126 static _bz_forceinline void
131
136 template<typename T_numtype, typename T_expr, typename T_update>
137 static _bz_forceinline void
138 evaluate_aligned(T_numtype* data, const T_expr& expr, T_update) {
139#ifdef BZ_USE_ALIGNMENT_PRAGMAS
140 //#pragma ivdep
141 //#pragma vector aligned
142#endif
144 }
145
150 template<typename T_numtype, typename T_expr, typename T_update>
151 static _bz_forceinline void
152 evaluate_unaligned(T_numtype* data, const T_expr& expr, T_update) {
153 //#pragma ivdep
154 //#pragma vector unaligned
156 }
157};
158
159
163template<typename P_numtype, int N_rows, int N_columns>
164template<typename T_expr, typename T_update>
166void
168{
169 const bool mixed_expr =
170 (T_expr::numArrayOperands>0) ||
171 (T_expr::numTVOperands>0) ||
172 (T_expr::numIndexPlaceholders>0);
174}
175
176
177}
178
179#endif // BZ_TVEVALUATE_H
Definition memblock.h:307
MemoryBlockReference()
Definition memblock.h:367
void _tm_evaluate(const T_expr &expr, T_update)
Definition prettyprint.h:40
#define true
Definition compiler.h:101
Definition array-impl.h:66
static _bz_forceinline void select_evaluation(TinyMatrix< T, N_rows, N_columns > &dest, const T_expr &expr, T_update)
The false version of select_evaluation is picked for expressions that contain operands other than Tin...
Definition tmevaluate.h:127
static _bz_forceinline void evaluate_aligned(T_numtype *data, const T_expr &expr, T_update)
This version of the evaluation function assumes that the TinyMatrixs have appropriate alignment (as w...
Definition tmevaluate.h:138
static _bz_forceinline void evaluate_unaligned(T_numtype *data, const T_expr &expr, T_update)
This version of the evaluation function is used when vectorizing expressions that we know can't be al...
Definition tmevaluate.h:152
The _tm_evaluator class has a bool template argument that is used to select code paths at compile tim...
Definition tmevaluate.h:45
static _bz_forceinline void select_evaluation(TinyMatrix< T, N_rows, N_columns > &dest, const T_expr &expr, T_update)
The select_evaluation function redirects expressions that do not contains solely TinyMatrix operands ...
Definition tmevaluate.h:57
static _bz_forceinline void evaluate_aligned(T_numtype *data, const T_expr &expr, T_update)
This version of the evaluation function assumes that the TinyMatrixs have appropriate alignment (as w...
Definition tmevaluate.h:93
static _bz_forceinline void evaluate_unaligned(T_numtype *data, const T_expr &expr, T_update)
This version of the evaluation function is used when vectorizing expressions that we know can't be al...
Definition tmevaluate.h:108
#define _bz_forceinline
Definition tuning.h:79
#define BZ_TV_EVALUATE_UNROLL_LENGTH
Definition tuning.h:64