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

Go to the source code of this file.

Macros

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

Functions

void vecacc (int n, float src1[n], float src2[n], float result[n])
 
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 14 of file vecacc.c.

15 {
16  int n;
17  float *src1, *src2, *result;
18  n = atoi(argv[1]);
19 
20 #define xmalloc(p) \
21  do { \
22  if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
23  return 3; \
24  } while(0);
25 
26 #define vmalloc(p)\
27  do { \
28  p=(float*)malloc(n*sizeof(float));\
29  } while(0);
30 
31  vmalloc(src1);
32  vmalloc(src2);
33  vmalloc(result);
34 
35  init_data_file(argv[2]);
36  init_data_float(src1, n);
37  init_data_float(src2, n);
39 
40  vecacc(n, src1, src2, result);
41 
42  free(src1);
43  free(src2);
44  free(result);
45 
46  return 0;
47 }
void free(void *)
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
void vecacc(int n, float src1[n], float src2[n], float result[n])
Definition: vecacc.c:7
#define vmalloc(p)

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

+ Here is the call graph for this function:

◆ vecacc()

void vecacc ( int  n,
float  src1[n],
float  src2[n],
float  result[n] 
)

Definition at line 7 of file vecacc.c.

8 {
9  int i;
10  for(i=0;i<n;i++)
11  result[i]+=src1[i]*src2[i];
12 }

Referenced by main().

+ Here is the caller graph for this function: