From fb09e470e40f1de8034258769bb8b4b522467e2b Mon Sep 17 00:00:00 2001 From: pmfsq5yrv <1159971203@qq.com> Date: Sat, 23 Nov 2024 16:05:48 +0800 Subject: [PATCH] Delete '1.c' --- 1.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 1.c diff --git a/1.c b/1.c deleted file mode 100644 index cb92f06..0000000 --- a/1.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include - -#define SIZE 10000000 - -void vectorAdd(float* A, float* B, float* C, int size) { - int i; - for (i = 0; i < size; ++i) { - C[i] = A[i] + B[i]; - } -} - -int main() { - float* A = (float*)malloc(SIZE * sizeof(float)); - float* B = (float*)malloc(SIZE * sizeof(float)); - float* C = (float*)malloc(SIZE * sizeof(float)); - if (A == NULL || B == NULL || C == NULL) { - return 1; - } - - // float A[SIZE], B[SIZE], C[SIZE]; - srand((unsigned)time(NULL)); - int i; - for (i = 0; i < SIZE; ++i) { - A[i] = rand() % 100; - B[i] = rand() % 100; - } - - - clock_t start_time = clock(); - - vectorAdd(A, B, C, SIZE); - - clock_t end_time = clock(); - double time = (double)(end_time - start_time) / CLOCKS_PER_SEC; - - printf("%f\n", time); - - // for (i = 0; i < SIZE; ++i) { - // printf("A[%d] + B[%d] = C[%d] -> %f + %f = %f\n", i, i, i, A[i], B[i], C[i]); - // } - - free(A); - free(B); - free(C); - return 0; -}