TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
simd_tools.h
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef simd_tools_included
17#define simd_tools_included
18
19#include <Simd_Array_template.h>
20#include <Simd_VectorArray_template.h>
21#include <Simd_MatrixArray_template.h>
22
23template<typename _TYPE_>
25{
26 return SimdMax(a, b);
27}
28
29template<typename _TYPE_>
31{
32 return SimdMin(a, b);
33}
34
35inline Simd_float select_float(Simd_float x1, Simd_float x2, Simd_float value_if_x1_lower_than_x2, Simd_float value_otherwise)
36{
37 return SimdSelect(x1, x2, value_if_x1_lower_than_x2, value_otherwise);
38}
39inline float select_float(float x1, float x2, float value_if_x1_lower_than_x2, float value_otherwise)
40{
41 return (x1 < x2) ? value_if_x1_lower_than_x2 : value_otherwise;
42}
43
44inline Simd_double select_double(Simd_double x1, Simd_double x2, Simd_double value_if_x1_lower_than_x2, Simd_double value_otherwise)
45{
46 return SimdSelect(x1, x2, value_if_x1_lower_than_x2, value_otherwise);
47}
48inline double select_double(double x1, double x2, double value_if_x1_lower_than_x2, double value_otherwise)
49{
50 return (x1 < x2) ? value_if_x1_lower_than_x2 : value_otherwise;
51}
52
53#endif /* simd_tools_included */
This class provides a generic access to simd operations on x86, x86 AMD and ARM architectures.