Files
2025-10-25 03:02:53 +03:00

102 lines
4.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[simd.general]
# 29 Numerics library [[numerics]](./#numerics)
## 29.10 Data-parallel types [[simd]](simd#general)
### 29.10.1 General [simd.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16144)
Subclause [[simd]](simd "29.10Data-parallel types") defines data-parallel types and operations on these types[.](#1.sentence-1)
[*Note [1](#note-1)*:
The intent is to support acceleration through data-parallel execution resources
where available, such as SIMD registers and instructions or execution units
driven by a common instruction decoder[.](#1.sentence-2)
SIMD stands for “Single Instruction Stream – Multiple Data Stream”;
it is defined in Flynn 1966[[bib]](bibliography#bib:flynn-taxonomy "Bibliography")[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16154)
The set of [*vectorizable types*](#def:type,vectorizable "29.10.1General[simd.general]") comprises
- [(2.1)](#2.1)
all standard integer types, character types, and the types float and double ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"));
- [(2.2)](#2.2)
std::float16_t, std::float32_t, and std::float64_t if defined ([[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")); and
- [(2.3)](#2.3)
complex<T> where T is a vectorizable floating-point type[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16167)
The term [*data-parallel type*](#def:type,data-parallel "29.10.1General[simd.general]") refers to all enabled specializations of
the basic_vec and basic_mask class templates[.](#3.sentence-1)
A [*data-parallel object*](#def:object,data-parallel "29.10.1General[simd.general]") is an object of data-parallel type[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16172)
Each specialization of basic_vec or basic_mask is either
enabled or disabled, as described in [[simd.overview]](simd.overview "29.10.7.1Class template basic_­vec overview") and[[simd.mask.overview]](simd.mask.overview "29.10.9.1Class template basic_­mask overview")[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16177)
A data-parallel type consists of one or more elements of an underlying
vectorizable type, called the [*element type*](#def:type,element "29.10.1General[simd.general]")[.](#5.sentence-1)
The number of elements is a constant for each data-parallel type and called the[*width*](#def:width "29.10.1General[simd.general]") of that type[.](#5.sentence-2)
The elements in a data-parallel type are indexed from 0 to width−1[.](#5.sentence-3)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16184)
An [*element-wise operation*](#def:operation,element-wise "29.10.1General[simd.general]") applies a specified operation to the
elements of one or more data-parallel objects[.](#6.sentence-1)
Each such application is unsequenced with respect to the others[.](#6.sentence-2)
A [*unary element-wise operation*](#def:operation,unary_element-wise "29.10.1General[simd.general]") is an element-wise operation that
applies a unary operation to each element of a data-parallel object[.](#6.sentence-3)
A [*binary element-wise operation*](#def:operation,binary_element-wise "29.10.1General[simd.general]") is an element-wise operation that
applies a binary operation to corresponding elements of two data-parallel
objects[.](#6.sentence-4)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16194)
Given a basic_mask<Bytes, Abi> object mask, the[*selected indices*](#def:indices,selected "29.10.1General[simd.general]") signify the integers i in the range
[0, mask.size()) for which mask[i] is true[.](#7.sentence-1)
Given a data-parallel object data, the [*selected elements*](#def:elements,selected "29.10.1General[simd.general]") signify the elements data[i] for all selected indices i[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L16201)
The conversion from an arithmetic type U to a vectorizable typeT is [*value-preserving*](#def:value-preserving "29.10.1General[simd.general]") if all possible values of U can be
represented with type T[.](#8.sentence-1)