-
Notifications
You must be signed in to change notification settings - Fork 1
/
iterative.c
49 lines (32 loc) · 958 Bytes
/
iterative.c
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
/*
iterative.c
Jordan Kremer
Dalton Bohning
*/
#include <stdio.h>
#include <time.h>
#include "common.h"
int main(void)
{
float *X = (float*) malloc(ARRAY_SIZE * sizeof(float));
float *Y = (float*) malloc(ARRAY_SIZE * sizeof(float));
initArray(X, ARRAY_SIZE);
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC_RAW, &start);
parallelScan_iterative(X, Y, ARRAY_SIZE);
clock_gettime(CLOCK_MONOTONIC_RAW, &end);
float execTime = (double) (end.tv_sec - start.tv_sec) * 1000 + (double) (end.tv_nsec - start.tv_nsec) / 1000000;
//Make sure the results are correct
#if defined(PRINT_RESULTS)
printArray(Y, ARRAY_SIZE);
#endif
#if defined(VERIFY_RESULTS)
if (verify(X, Y, ARRAY_SIZE))
printf("ALL CORRECT!\n");
else
printf("FAIL!\n");
#endif
printf("Execution (ms): %f\n", execTime);
free(X);
free(Y);
}