Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Simd.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Simd.cc (C) 2000-2018 */
9/* */
10/* Types for vectorization. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/Simd.h"
17#include "arcane/utils/Iostream.h"
18#include "arcane/utils/FatalErrorException.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \defgroup ArcaneSimd Vectorization
31 *
32 * Set of classes managing vectorization.
33 * For more information, refer to the page \ref arcanedoc_parallel_simd.
34 */
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39namespace
40{
41 template <typename SimdRealType> void
42 _printSimd(std::ostream& o, const SimdRealType& s)
43 {
44 for (Integer z = 0, n = SimdRealType::BLOCK_SIZE; z < n; ++z) {
45 if (z != 0)
46 o << ' ';
47 o << s[z];
48 }
49 }
50} // namespace
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55#ifdef ARCANE_HAS_AVX512
56std::ostream&
57operator<<(std::ostream& o, const AVX512SimdReal& s)
58{
59 _printSimd(o, s);
60 return o;
61}
62#endif
63
64#ifdef ARCANE_HAS_AVX
65std::ostream&
66operator<<(std::ostream& o, const AVXSimdReal& s)
67{
68 _printSimd(o, s);
69 return o;
70}
71#endif
72
73#ifdef ARCANE_HAS_SSE
74std::ostream&
75operator<<(std::ostream& o, const SSESimdReal& s)
76{
77 _printSimd(o, s);
78 return o;
79}
80#endif
81
82std::ostream&
83operator<<(std::ostream& o, const EMULSimdReal& s)
84{
85 _printSimd(o, s);
86 return o;
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92void SimdEnumeratorBase::
93_checkValidHelper()
94{
95 arcaneCheckAlignment(m_local_ids, SimdIndexType::Alignment);
96 if (!arcaneIsCheck())
97 return;
98 Integer size = m_count;
99 if (size == 0)
100 return;
101 Integer padding_size = arcaneSizeWithPadding(size);
102 if (padding_size == size)
103 return;
104
105 // Checks that the padding is done with the last valid value.
106 Int32 last_local_id = m_local_ids[size - 1];
107 for (Integer k = size; k < padding_size; ++k)
108 if (m_local_ids[k] != last_local_id)
109 ARCANE_FATAL("Bad padding value i={0} expected={1} value={2}",
110 k, last_local_id, m_local_ids[k]);
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116} // namespace Arcane
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Vectorization of reals using AVX512 vectorization.
Definition SimdAVX512.h:43
Real vectorization using emulation.
Definition SimdEMUL.h:202
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
bool arcaneIsCheck()
True if running in check mode.
Definition Misc.cc:66
AVXSimdX4Real AVXSimdReal
Vector of 'double' in SSE implementation.
Definition SimdAVX.h:365
Int32 Integer
Type representing an integer.
Integer arcaneSizeWithPadding(Integer size)
Returns the size with padding for a size size.
SSESimdX4Real SSESimdReal
Vector of 'double' in SSE implementation.
Definition SimdSSE.h:420
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Output operator for a stream.
void arcaneCheckAlignment(const void *ptr, Integer alignment)
Checks that ptr is aligned on alignment bytes. If not, throws a BadAlignmentException.
std::int32_t Int32
Signed integer type of 32 bits.