-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwiden_narrow.cpp
79 lines (67 loc) · 1.98 KB
/
widen_narrow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "riscv_vector.h"
extern "C" {
void widen_float2double(uint64_t n, double *__restrict dst,
const float *__restrict src) {
for (int i = 0; i < n; i++) {
dst[i] = src[i];
}
}
void widen_float2long(uint64_t n, long *__restrict dst,
const float *__restrict src) {
for (int i = 0; i < n; i++) {
dst[i] = src[i];
}
}
void narrow_double2float(uint64_t n, float *__restrict dst,
const double *__restrict src) {
for (int i = 0; i < n; i++) {
dst[i] = src[i];
}
}
void fadd_float2double(uint64_t n, double *__restrict dst,
const float *__restrict x, const float *__restrict y) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] + y[i];
}
}
void fma_float2double(uint64_t n, double *__restrict dst,
const float *__restrict x, const float *__restrict y,
const float *__restrict z) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] * y[i] + z[i];
}
}
void fadd_mixed2double(uint64_t n, double *__restrict dst,
const double *__restrict x, const float *__restrict y) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] + y[i];
}
}
void add_int2long(uint64_t n, long *__restrict dst, const int *__restrict x,
const int *__restrict y) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] + y[i];
}
}
void mul_int2long(uint64_t n, long *__restrict dst, const int *__restrict x,
const int *__restrict y) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] * y[i];
}
}
void mul_uint2ulong(uint64_t n, unsigned long *__restrict dst,
const unsigned int *__restrict x,
const unsigned int *__restrict y) {
for (int i = 0; i < n; i++) {
dst[i] = x[i] * y[i];
}
}
double sum_float2double(uint64_t n, const float *__restrict x) {
double res = 0;
#pragma clang loop vectorize(enable)
for (int i = 0; i < n; i++) {
res += x[i];
}
return res;
}
}