ADD file via upload

main
pc9ha2xvl 2 months ago
parent f2daf8de29
commit 10a3723aa2

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 1024
void vector_add(float* A, float* B, float* C, int size) {
int i;
for (i = 0; i < size; i++) {
C[i] = A[i] + B[i];
}
}
int main() {
int i;
float A[SIZE], B[SIZE], C[SIZE];
srand((unsigned int)time(NULL));
for (i = 0; i < SIZE; i++) {
A[i] = rand() % 100;
B[i] = rand() % 100;
}
clock_t start_time = clock();
vector_add(A, B, C, SIZE);
clock_t end_time = clock();
double elapsed_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
printf(" %f s\n", elapsed_time);
return 0;
}
Loading…
Cancel
Save