parent
317d2131d7
commit
a29137f76a
@ -1,34 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <ctime>
|
||||
#include <arm_neon.h>
|
||||
|
||||
#define SIZE 1024
|
||||
|
||||
void inArry(float a[]) {
|
||||
srand(time(NULL));
|
||||
for (int i = 0; i < SIZE; i++)
|
||||
{
|
||||
a[i] = rand() % 100;
|
||||
}
|
||||
}
|
||||
|
||||
void vector_add_optimized(float* A, float* B, float* C, int size) {
|
||||
for (int i = 0; i < SIZE; i += 4) {
|
||||
float32x4_t vecA = vld1q_f32(&A[i]);
|
||||
float32x4_t vecB = vld1q_f32(&B[i]);
|
||||
float32x4_t vecC = vaddq_f32(vecA, vecB);
|
||||
vst1q_f32(&C[i], vecC);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
float A[SIZE], B[SIZE], C[SIZE];
|
||||
inArry(A);
|
||||
inArry(B);
|
||||
clock_t start = clock();
|
||||
vector_add_optimized(A, B, C, SIZE);
|
||||
clock_t end = clock();
|
||||
printf("%f", (double)(end - start) / CLOCKS_PER_SEC);
|
||||
}
|
Loading…
Reference in new issue