SuperDex Physics C++ API
Loading...
Searching...
No Matches
arm_simd_inl.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) Meta Platforms, Inc. and affiliates.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
/**
20
This file contains Simd specializations for ARM CPUs with NEON support.
21
*/
22
23
#include "
../../simd.h
"
// for IntelliSense
24
25
#if MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
26
27
#include <arm_neon.h>
28
29
/***********************************************************************************************
30
Simd Specializations for ARM Architecture
31
*/
32
33
// NOTE: Order of these headers matters in some cases. Do not sort alphabetically.
34
35
#include "
arm_simd_tables_inl.h
"
36
37
#include "
arm_simd_int_4_inl.h
"
38
39
#include "
arm_simd_int64_2_inl.h
"
40
41
#include "
arm_simd_double_2_inl.h
"
42
43
#include "
arm_simd_float_4_inl.h
"
44
45
/***********************************************************************************************
46
Simd Utilities for ARM Architecture
47
*/
48
49
namespace
superdex
{
50
51
// clang-format off
52
template
<>
MOCHI_FORCE_INLINE
Simd<double, 2>
StaticCast<Simd<double, 2>
,
Simd<int64_t, 2>
>(
Simd<int64_t, 2>
const
& a) {
return
vcvtq_f64_s64(a.raw); }
53
template
<>
MOCHI_FORCE_INLINE
Simd<int64_t, 2>
StaticCast<Simd<int64_t, 2>
,
Simd<double, 2>
>(
Simd<double, 2>
const
& a) {
return
vcvtq_s64_f64(a.raw); }
54
template
<>
MOCHI_FORCE_INLINE
Simd<float, 4>
StaticCast<Simd<float, 4>
,
Simd<int, 4>
>(
Simd<int, 4>
const
& a) {
return
vcvtq_f32_s32(a.raw); }
55
template
<>
MOCHI_FORCE_INLINE
Simd<int, 4>
StaticCast<Simd<int, 4>
,
Simd<float, 4>
>(
Simd<float, 4>
const
& a) {
return
vcvtq_s32_f32(a.raw); }
56
57
template
<>
MOCHI_FORCE_INLINE
Simd<double, 2>
ReinterpretCast<Simd<double, 2>,
Simd<int64_t, 2>
>(
Simd<int64_t, 2>
const
& a) {
return
vreinterpretq_f64_s64(a.raw); }
58
template
<>
MOCHI_FORCE_INLINE
Simd<double, 2>
ReinterpretCast<Simd<double, 2>,
Simd<float, 4>
>(
Simd<float, 4>
const
& a) {
return
vreinterpretq_f64_f32(a.raw); }
59
template
<>
MOCHI_FORCE_INLINE
Simd<double, 2>
ReinterpretCast<Simd<double, 2>,
Simd<int, 4>
>(
Simd<int, 4>
const
& a) {
return
vreinterpretq_f64_s32(a.raw); }
60
template
<>
MOCHI_FORCE_INLINE
Simd<int64_t, 2>
ReinterpretCast<Simd<int64_t, 2>,
Simd<double, 2>
>(
Simd<double, 2>
const
& a) {
return
vreinterpretq_s64_f64(a.raw); }
61
template
<>
MOCHI_FORCE_INLINE
Simd<int64_t, 2>
ReinterpretCast<Simd<int64_t, 2>,
Simd<float, 4>
>(
Simd<float, 4>
const
& a) {
return
vreinterpretq_s64_f32(a.raw); }
62
template
<>
MOCHI_FORCE_INLINE
Simd<int64_t, 2>
ReinterpretCast<Simd<int64_t, 2>,
Simd<int, 4>
>(
Simd<int, 4>
const
& a) {
return
vreinterpretq_s64_s32(a.raw); }
63
template
<>
MOCHI_FORCE_INLINE
Simd<float, 4>
ReinterpretCast<Simd<float, 4>,
Simd<double, 2>
>(
Simd<double, 2>
const
& a) {
return
vreinterpretq_f32_f64(a.raw); }
64
template
<>
MOCHI_FORCE_INLINE
Simd<float, 4>
ReinterpretCast<Simd<float, 4>,
Simd<int64_t, 2>
>(
Simd<int64_t, 2>
const
& a) {
return
vreinterpretq_f32_s64(a.raw); }
65
template
<>
MOCHI_FORCE_INLINE
Simd<float, 4>
ReinterpretCast<Simd<float, 4>,
Simd<int, 4>
>(
Simd<int, 4>
const
& a) {
return
vreinterpretq_f32_s32(a.raw); }
66
template
<>
MOCHI_FORCE_INLINE
Simd<int, 4>
ReinterpretCast<Simd<int, 4>,
Simd<double, 2>
>(
Simd<double, 2>
const
& a) {
return
vreinterpretq_s32_f64(a.raw); }
67
template
<>
MOCHI_FORCE_INLINE
Simd<int, 4>
ReinterpretCast<Simd<int, 4>,
Simd<int64_t, 2>
>(
Simd<int64_t, 2>
const
& a) {
return
vreinterpretq_s32_s64(a.raw); }
68
template
<>
MOCHI_FORCE_INLINE
Simd<int, 4>
ReinterpretCast<Simd<int, 4>,
Simd<float, 4>
>(
Simd<float, 4>
const
& a) {
return
vreinterpretq_s32_f32(a.raw); }
69
// clang-format on
70
71
}
// namespace superdex
72
73
#endif
// MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
arm_simd_double_2_inl.h
arm_simd_float_4_inl.h
arm_simd_int64_2_inl.h
arm_simd_int_4_inl.h
arm_simd_tables_inl.h
superdex::Simd
Definition
simd.h:91
MOCHI_FORCE_INLINE
#define MOCHI_FORCE_INLINE
Definition
mochi_platform.h:340
superdex
Definition
mochi_prefab.h:32
superdex::StaticCast
constexpr To StaticCast(From const &a)
Definition
basic_utils.h:79
simd.h
mochi
mochi_core
include
mochi_core
utils
simd
arm
arm_simd_inl.h
Generated by
1.16.1