This file is indexed.

/usr/include/fflas-ffpack/fflas/fflas_fadd.inl is in fflas-ffpack-common 2.2.2-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s

/*
 * Copyright (C) 2014 FFLAS-FFPACK group
 *
 * Written by Brice Boyer (briceboyer) <boyer.brice@gmail.com>
 *
 *
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 *.
 */

#ifndef __FFLASFFPACK_fadd_INL
#define __FFLASFFPACK_fadd_INL

#include "fflas-ffpack/fflas/fflas_simd.h"

namespace FFLAS { namespace vectorised {

#ifdef __FFLASFFPACK_HAVE_SSE4_1_INSTRUCTIONS

	template<class SimdT, class Element, bool positive>
	inline typename std::enable_if<is_simd<SimdT>::value, void>::type
	VEC_ADD(SimdT & C, SimdT & A, SimdT & B, SimdT & Q, SimdT & T, SimdT & P, SimdT & NEGP, SimdT & MIN, SimdT & MAX)
	{
		using simd = Simd<Element>;
		C = simd::add(A, B);
		Q = simd::vand(simd::greater(C, MAX),NEGP);
		if (!positive) {
			T = simd::vand(simd::lesser(C, MIN),P);
			Q = simd::vor(Q, T);
		}
		C = simd::add(C, Q);
	}

	template<bool positive, class Element, class T1, class T2>
	inline typename std::enable_if<FFLAS::support_simd_add<Element>::value, void>::type
	addp(Element * T, const Element * TA, const Element * TB,  size_t n,  Element p,  T1 min_,  T2 max_)
	{
		Element min= (Element)min_, max= (Element)max_;
		using simd = Simd<Element>;
		using vect_t = typename simd::vect_t;

		size_t i = 0;

		if (n < simd::vect_size)
		{
			for (; i < n ; i++)
			{
				T[i] = TA[i] + TB[i];
				T[i] -= (T[i] > max) ? p : 0;
				if (!positive)
				{
					T[i] += (T[i] < min) ? p : 0;
				}
			}
			return;

		}

		vect_t A,B,C,Q,P,NEGP,TMP,MIN,MAX;
		P   = simd::set1(p);
		NEGP= simd::set1(-p);
		MIN = simd::set1(min);
		MAX = simd::set1(max);
		long st = long(T)%simd::alignment;
		if (st)
		{ // the array T is not 32 byte aligned (process few elements s.t. (T+i) is 32 bytes aligned)
			for (size_t j=static_cast<size_t>(st) ; j < simd::alignment ; j += sizeof(Element), i++)
			{
				T[i] = TA[i] + TB[i];
				T[i] -= (T[i] > max) ? p : 0;
				if (!positive)
					T[i] += (T[i] < min) ? p : 0;
			}
		}
		FFLASFFPACK_check((long(T+i) % simd::alignment == 0));
		if ( (long(TA+i)%simd::alignment==0) && (long(TB+i)%simd::alignment==0))
		{
			// perform the loop using 256 bits SIMD
			for (; i <= n - simd::vect_size ; i += simd::vect_size)
			{
				// C = simd::load(T+i);
				A = simd::load(TA+i);
				B = simd::load(TB+i);
				VEC_ADD<vect_t,Element,positive>(C, A, B, Q, TMP, P, NEGP, MIN, MAX);
				simd::store(T+i, C);
			}
		}
		// perform the last elt from T without SIMD
		for (; i < n ; i++)
		{
			T[i] = TA[i] + TB[i];
			T[i] -= (T[i] > max) ? p : 0;
			if (!positive)
				T[i] += (T[i] < min) ? p : 0;
		}
	}

	template<class SimdT, class Element,bool positive>
	inline typename std::enable_if<is_simd<SimdT>::value, void>::type
	VEC_SUB(SimdT & C, SimdT & A, SimdT & B, SimdT & Q, SimdT & T, SimdT & P, SimdT & NEGP, SimdT & MIN, SimdT & MAX)
	{
		using simd = Simd<Element>;
		C = simd::sub(A, B);
		T = simd::vand(simd::lesser(C, MIN),P);
		if (!positive) {
			Q = simd::vand(simd::greater(C, MAX),NEGP);
			T = simd::vor(Q, T);
		}
		C = simd::add(C, T);
	}

	template<bool positive, class Element, class T1, class T2>
	inline typename std::enable_if<FFLAS::support_simd_add<Element>::value, void>::type
	subp(Element * T, const Element * TA, const Element * TB, const size_t n, const Element p, const T1 min_, const T2 max_)
	{
		Element min = (Element)min_, max = (Element)max_;
		using simd = Simd<Element>;
		using vect_t = typename simd::vect_t;

		size_t i = 0;

		if (n < simd::vect_size)
		{
			for (; i < n ; i++)
			{
				T[i] = TA[i] - TB[i];
				if (!positive)
					T[i] -= (T[i] > max) ? p : 0;
				T[i] += (T[i] < min) ? p : 0;
			}
			return;

		}
		vect_t A,B,C,Q,P,NEGP,TMP,MIN,MAX;
		P   = simd::set1(p);
		NEGP= simd::set1(-p);
		MIN = simd::set1(min);
		MAX = simd::set1(max);
		long st = long(T) % simd::alignment;
		if (st)
		{ // the array T is not 32 byte aligned (process few elements s.t. (T+i) is 32 bytes aligned)
			for (size_t j = static_cast<size_t>(st) ; j < simd::alignment ; j += sizeof(Element), i++)
			{
				T[i] = TA[i] - TB[i];
				if (!positive)
					T[i] -= (T[i] > max) ? p : 0;
				T[i] += (T[i] < min) ? p : 0;
			}
		}
		FFLASFFPACK_check((long(T+i) % simd::alignment == 0));
		if ( (long(TA+i) % simd::alignment == 0) && (long(TB+i) % simd::alignment == 0))
		{
			// perform the loop using 256 bits SIMD
			for (; i <= n - simd::vect_size ; i += simd::vect_size)
			{
				// C = simd::load(T+i);
				A = simd::load(TA+i);
				B = simd::load(TB+i);
				VEC_SUB<vect_t,Element,positive>(C, A, B, Q, TMP, P, NEGP, MIN, MAX);
				simd::store(T+i, C);
			}
		}

		// perform the last elt from T without SIMD
		for (; i < n ; i++)
		{
			T[i] = TA[i] - TB[i];
			if (!positive)
				T[i] -= (T[i] > max) ? p : 0;
			T[i] += (T[i] < min) ? p : 0;
		}
	}

#else // no simd, but faster than F.init()
	template<bool positive, class Element, class T1, class T2>
	// inline typename std::enable_if<!FFLAS::support_simd_add<Element>::value, void>::type
	void
	subp(Element * T, const Element * TA, const Element * TB, const size_t n, const Element p, const T1 min_, const T2 max_)
	{
		Element min = (Element)min_, max = (Element)max_;

		size_t i = 0;

			for (; i < n ; i++)
			{
				T[i] = TA[i] - TB[i];
				if (!positive)
					T[i] -= (T[i] > max) ? p : 0;
				T[i] += (T[i] < min) ? p : 0;
			}
			return;

	}

	template<bool positive, class Element, class T1, class T2>
	// inline typename std::enable_if<!FFLAS::support_simd_add<Element>::value, void>::type
	void
	addp(Element * T, const Element * TA, const Element * TB,  const size_t n,  const Element p,  const T1 min_,  const T2 max_)
	{
		Element min= (Element)min_, max= (Element)max_;

		size_t i = 0;

		for (; i < n ; i++)
		{
			T[i] = TA[i] + TB[i];
			T[i] -= (T[i] > max) ? p : 0;
			if (!positive)
			{
				T[i] += (T[i] < min) ? p : 0;
			}
		}
		return;
	}


#endif // __FFLASFFPACK_HAVE_SSE4_1_INSTRUCTIONS

} // vectorised
} //  FFLAS

namespace FFLAS { namespace details {

	/**** Specialised ****/

	template <class Field, bool ADD>
	typename std::enable_if<FFLAS::support_simd_add<typename Field::Element>::value, void>::type
	fadd (const Field & F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc
	      , FieldCategories::ModularTag
	     )
	{
		if (inca == 1 && incb == 1 && incc == 1) {
			typename Field::Element p = (typename Field::Element) F.characteristic();
			if (ADD)
				FFLAS::vectorised::addp<!FieldTraits<Field>::balanced>(C,A,B,N,p,F.minElement(),F.maxElement());
			else
				FFLAS::vectorised::subp<!FieldTraits<Field>::balanced>(C,A,B,N,p,F.minElement(),F.maxElement());
		}
		else {
			for (size_t i=0; i<N; i++)
				if (ADD)
					F.add (C[i*incc], A[i*inca], B[i*incb]);
				else
					F.sub (C[i*incc], A[i*inca], B[i*incb]);
		}
	}

	template <class Field, bool ADD>
	typename std::enable_if<!FFLAS::support_simd_add<typename Field::Element>::value, void>::type
	fadd (const Field & F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc
	      , FieldCategories::ModularTag
	     )
	{
		if (inca == 1 && incb == 1 && incc == 1) {
				for (size_t i=0; i<N; i++)
				if (ADD)
					F.add (C[i], A[i], B[i]);
				else
					F.sub (C[i], A[i], B[i]);
		}
		else {
			for (size_t i=0; i<N; i++)
				if (ADD)
				F.add (C[i*incc], A[i*inca], B[i*incb]);
				else
				F.sub (C[i*incc], A[i*inca], B[i*incb]);
		}
	}



	template <class Field, bool ADD>
	void
	fadd (const Field & F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc
	      , FieldCategories::GenericTag
	      )
	{
		if (inca == 1 && incb == 1 && incc == 1) {
			for (size_t i=0; i<N; i++) {
				if (ADD)
				F.add (C[i], A[i], B[i]);
				else
				F.sub (C[i], A[i], B[i]);
			}
		}
		else {
			for (size_t i=0; i<N; i++)
				if (ADD)
				F.add (C[i*incc], A[i*inca], B[i*incb]);
				else
				F.add (C[i*incc], A[i*inca], B[i*incb]);
		}
	}

	template <class Field, bool ADD>
	void
	fadd (const Field & F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc
	      , FieldCategories::UnparametricTag
	     )
	{
		for (size_t i=0; i<N; i++)
			if (ADD)
				C[i] = A[i] + B[i];
			else
				C[i] = A[i] - B[i];
	}



} // details
} // FFLAS


#endif // __FFLASFFPACK_fscal_INL