-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (35 loc) · 1.02 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (35 loc) · 1.02 KB
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
#include <arm_neon.h>
void add3 (uint8x16_t *data) {
/* Set each sixteen values of the vector to 3.
*
* Remark: a 'q' suffix to intrinsics indicates
* the instruction run for 128 bits registers.
*/
uint8x16_t three = vmovq_n_u8 (3);
/* Add 3 to the value given in argument. */
*data = vaddq_u8 (*data, three);
}
void print_uint8 (uint8x16_t data, char* name) {
int i;
static uint8_t p[16];
vst1q_u8 (p, data);
printf ("%s = ", name);
for (i = 0; i < 16; i++) {
printf ("%02d ", p[i]);
}
printf ("\n");
}
int main () {
/* Create custom arbitrary data. */
const uint8_t uint8_data[] = { 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16 };
/* Create the vector with our data. */
uint8x16_t data;
/* Load our custom data into the vector register. */
data = vld1q_u8 (uint8_data);
print_uint8 (data, "data");
/* Call of the add3 function. */
add3(&data);
print_uint8 (data, "data (new)");
return 0;
}