PIPS
vecacc-aligned.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+ Include dependency graph for vecacc-aligned.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 15 of file vecacc-aligned.c.

16 {
17  int n;
18  float *src1, *src2, *result;
19  n = atoi(argv[1]);
20 
21 #define xmalloc(p) \
22  do { \
23  if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
24  return 3; \
25  } while(0);
26 #define vmalloc(p)\
27  do {\
28  p=(float*)malloc(n*sizeof(float));\
29  } while(0)
30 
31  xmalloc(src1);
32  xmalloc(src2);
33  xmalloc(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  print_array_float("result", result, n);
43 
44  free(src1);
45  free(src2);
46  free(result);
47 
48  return 0;
49 }
void free(void *)
void close_data_file()
Definition: tools.c:48
void print_array_float(const char *name, const float *arr, const unsigned int n)
Definition: tools.c:54
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 xmalloc(p)
void vecacc(int n, float *src1, float *src2, float *result)
Definition: vecacc-aligned.c:6

References close_data_file(), free(), init_data_file(), init_data_float(), print_array_float(), vecacc(), and xmalloc.

+ Here is the call graph for this function:

◆ vecacc()

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

Definition at line 6 of file vecacc-aligned.c.

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

Referenced by main().

+ Here is the caller graph for this function: