12#ifndef ARCANE_UTILS_SIMD_H
13#define ARCANE_UTILS_SIMD_H
17#include "arcane/utils/SimdCommon.h"
18#include "arcane/utils/Real3.h"
19#include "arcane/utils/Real2.h"
20#include "arcane/utils/Real3x3.h"
21#include "arcane/utils/Real2x2.h"
22#include "arcane/utils/ArrayView.h"
70#include "arcane/utils/SimdEMUL.h"
73#if (defined(_M_X64) || defined(__x86_64__)) && !defined(ARCANE_NO_SSE)
79#include "arcane/utils/SimdSSE.h"
83#if defined(ARCANE_HAS_AVX) || defined(ARCANE_HAS_AVX512)
85#include "arcane/utils/SimdAVX.h"
89#if defined(ARCANE_HAS_AVX512)
91#include "arcane/utils/SimdAVX512.h"
101#define ENUMERATE_SIMD_REAL(_iter) \
102 for (::Arcane::Integer _iter(0); _iter < SimdReal ::BLOCK_SIZE; ++_iter)
117#if defined(ARCANE_HAS_AVX512)
118typedef AVX512SimdInfo SimdInfo;
119#elif defined(ARCANE_HAS_AVX)
120typedef AVXSimdInfo SimdInfo;
121#elif defined(ARCANE_HAS_SSE)
122typedef SSESimdInfo SimdInfo;
124typedef EMULSimdInfo SimdInfo;
135const int SimdSize = SimdReal::Length;
150class ARCANE_UTILS_EXPORT SimdReal3
154 typedef SimdReal::Int32IndexType Int32IndexType;
167 SimdReal3(
const Real3* base,
const Int32IndexType& idx)
169 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
170 Real3 v = base[idx[i]];
176 void set(
Real3* base,
const Int32IndexType& idx)
const
178 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
179 base[idx[i]] = this->get(i);
192 return Real3(x[i], y[i], z[i]);
203class ARCANE_UTILS_EXPORT SimdReal2
207 typedef SimdReal::Int32IndexType Int32IndexType;
218 SimdReal2(
const Real2* base,
const Int32IndexType& idx)
220 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
221 Real2 v = base[idx[i]];
227 void set(
Real2* base,
const Int32IndexType& idx)
const
229 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
230 base[idx[i]] = this->get(i);
241 return Real2(x[i], y[i]);
252class ARCANE_UTILS_EXPORT SimdReal3x3
256 typedef SimdReal::Int32IndexType Int32IndexType;
269 SimdReal3x3(
const Real3x3* base,
const Int32IndexType& idx)
271 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
278 void set(
Real3x3* base,
const Int32IndexType& idx)
const
280 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
281 base[idx[i]] = this->get(i);
294 return Real3x3(x[i], y[i], z[i]);
305class ARCANE_UTILS_EXPORT SimdReal2x2
309 typedef SimdReal::Int32IndexType Int32IndexType;
320 SimdReal2x2(
const Real2x2* base,
const Int32IndexType& idx)
322 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
329 void set(
Real2x2* base,
const Int32IndexType& idx)
const
331 for (
Integer i = 0, n = SimdReal::BLOCK_SIZE; i < n; ++i) {
332 base[idx[i]] = this->get(i);
358template <
typename DataType>
363 typedef void SimdType;
416class ARCANE_UTILS_EXPORT SimdEnumeratorBase
420 typedef SimdInfo::SimdInt32IndexType SimdIndexType;
425 : m_local_ids(
nullptr)
430 : m_local_ids(local_ids)
437 : m_local_ids(local_ids.data())
439 , m_count(local_ids.size())
446 bool hasNext() {
return m_index < m_count; }
451 void operator++() { m_index += SimdSize; }
459 Integer nb_valid = (m_count - m_index);
460 if (nb_valid > SimdSize)
465 Integer count()
const {
return m_count; }
469 const Int32* ARCANE_RESTRICT m_local_ids;
473 const SimdIndexType* ARCANE_RESTRICT
474 _currentSimdIndex()
const
476 return (
const SimdIndexType*)(m_local_ids + m_index);
484#ifdef ARCANE_SIMD_BENCH
485 Int64 modulo = (Int64)(m_local_ids) % SimdIndexType::Alignment;
487 throw BadAlignmentException();
493 void _checkValidHelper();
Class managing a 2-dimensional real vector.
Class managing a 2x2 matrix of reals.
Class managing a 3-dimensional real vector.
Class managing a 3x3 real matrix.
Real3 z
first element of the triplet
Real3 y
first element of the triplet
Real3 x
first element of the triplet
const Int32 * unguardedLocalIds() const
Local indices.
Integer nbValid() const
Number of valid values for the current iterator.
Represents a vectorized Real2.
Represents a vectorized Real2x2.
Represents a vectorized Real3.
Represents a vectorized Real3x3.
Characteristics of vector types.
SimdInfo::SimdReal SimdReal
SIMD vector of real numbers.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.
Real y
second component of the pair
Real x
first component of the pair
Real y
second component of the triplet
Real z
third component of the triplet
Real x
first component of the triplet