-
Notifications
You must be signed in to change notification settings - Fork 1
/
omp.c
37 lines (27 loc) · 794 Bytes
/
omp.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
#include "mxmultiply.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define LENGTH 1024
int main()
{
double cpu_time;
struct timespec start, end;
float *a = malloc(LENGTH * LENGTH * sizeof(float));
float *b = malloc(LENGTH * LENGTH * sizeof(float));
float *c = calloc(LENGTH * LENGTH, sizeof(float));
rmxinitf(LENGTH, a, 8);
rmxinitf(LENGTH, b, 5);
// start timer
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
mmxmultiplyf(LENGTH, a, b, c);
// end timer
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
cpu_time = (end.tv_nsec - start.tv_nsec) / 1000000000.0;
cpu_time += (end.tv_sec - start.tv_sec);
printf("execution time: %.5f s\n", cpu_time);
free(a);
free(b);
free(c);
return 0;
}