PIPS
vecacc-time.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include "tools.h"
+ Include dependency graph for vecacc-time.c:

Go to the source code of this file.

Macros

#define xmalloc(p)
 
#define vmalloc(p)
 

Functions

void vecacc (int n, float *src1, float *src2, float *result)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ vmalloc

#define vmalloc (   p)
Value:
do { \
p=(float*)malloc(n*sizeof(float));\
} while(0);
void * malloc(YYSIZE_T)

◆ xmalloc

#define xmalloc (   p)
Value:
do { \
if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
return 3; \
} while(0);

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file vecacc-time.c.

18 {
19  int n;
20  float *src1, *src2, *result;
21  n = atoi(argv[1]);
22 
23 #define xmalloc(p) \
24  do { \
25  if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
26  return 3; \
27  } while(0);
28 
29 #define vmalloc(p)\
30  do { \
31  p=(float*)malloc(n*sizeof(float));\
32  } while(0);
33 
34  vmalloc(src1);
35  vmalloc(src2);
36  vmalloc(result);
37 
38  init_data_file(argv[2]);
39  init_data_float(src1, n);
40  init_data_float(src2, n);
42 
43  //struct timeval start,end;
44  //gettimeofday(&start, NULL);
45  struct timespec start,end;
46  clock_gettime(CLOCK_MONOTONIC, &start);
47  vecacc(n, src1, src2, result);
48  clock_gettime(CLOCK_MONOTONIC, &end);
49  double tdiff = end.tv_sec*1000.0+(end.tv_nsec/1000000.0) - (start.tv_sec*1000.0+(start.tv_nsec/1000000.0));
50  printf("Time: %f\n", tdiff);
51 
52  free(src1);
53  free(src2);
54  free(result);
55 
56  return 0;
57 }
static char start[1024]
The name of the variable from which to start counting domain numbers.
Definition: genLisp.c:55
void free(void *)
char end
Definition: gtk_status.c:82
int printf()
void close_data_file()
Definition: tools.c:48
int init_data_float(float *ptr, const unsigned int n)
Definition: tools.c:125
void init_data_file(const char *data_file)
Definition: tools.c:36
#define vmalloc(p)
void vecacc(int n, float *src1, float *src2, float *result)
Definition: vecacc-time.c:8

References close_data_file(), end, free(), init_data_file(), init_data_float(), printf(), start, vecacc(), and vmalloc.

+ Here is the call graph for this function:

◆ vecacc()

void vecacc ( int  n,
float *  src1,
float *  src2,
float *  result 
)

pragma vector aligned pragma ivdep

Definition at line 8 of file vecacc-time.c.

9 {
10  int i;
11 /*#pragma vector aligned
12 #pragma ivdep*/
13  for(i=0;i<n;i++)
14  result[i]+=src1[i]*src2[i];
15 }

Referenced by main().

+ Here is the caller graph for this function: