tesseract  4.00.00dev
/home/stefan/src/github/tesseract-ocr/tesseract/dotproduct-main.cpp File Reference
#include <stdio.h>

Go to the source code of this file.

Functions

double DotProductAVX (const double *u, const double *v, int n)
 
double DotProductSIMD (const double *u, const double *v, int n)
 
double DotProduct (const double *u, const double *v, int n)
 
int main ()
 

Variables

const int max = 65536
 
double u [max]
 
double v [max]
 

Function Documentation

◆ DotProduct()

double DotProduct ( const double *  u,
const double *  v,
int  n 
)

Definition at line 90 of file dotproduct-test.cpp.

90  {
91  double total = 0.0;
92  for (int k = 0; k < n; ++k) total += u[k] * v[k];
93  return total;
94 }
double u[max]
double v[max]

◆ DotProductAVX()

double DotProductAVX ( const double *  u,
const double *  v,
int  n 
)

Definition at line 27 of file dotproductavx.cpp.

27  {
28  fprintf(stderr, "DotProductAVX can't be used on Android\n");
29  abort();
30 }

◆ DotProductSIMD()

double DotProductSIMD ( const double *  u,
const double *  v,
int  n 
)

Definition at line 79 of file dotproduct-test.cpp.

79  {
80  double total = 0.0;
81 #ifdef _OPENMP
82 #pragma omp simd aligned(u, v: 32)
83 #else
84 #error
85 #endif
86  for (int k = 0; k < n; ++k) total += u[k] * v[k];
87  return total;
88 }
double u[max]
double v[max]

◆ main()

int main ( )

Definition at line 12 of file dotproduct-main.cpp.

12  {
13 #if 0
14  // 5.6
15  printf("DotProduct\n");
16  for (unsigned i = 0; i < 1000000; i++)
17  DotProduct(u, v, max);
18 #elif 0
19  // 5.6
20  printf("DotProductSIMD\n");
21  for (unsigned i = 0; i < 1000000; i++)
22  DotProductSIMD(u, v, max);
23 #else
24  // 1.5
25  printf("DotProductAVX\n");
26  for (unsigned i = 0; i < 1000000; i++)
27  DotProductAVX(u, v, max);
28 #endif
29  return 0;
30 }
double u[max]
double DotProduct(const double *u, const double *v, int n)
const int max
double DotProductSIMD(const double *u, const double *v, int n)
double DotProductAVX(const double *u, const double *v, int n)
double v[max]

Variable Documentation

◆ max

const int max = 65536

Definition at line 3 of file dotproduct-main.cpp.

◆ u

double u[max]

Definition at line 5 of file dotproduct-main.cpp.

◆ v

double v[max]

Definition at line 6 of file dotproduct-main.cpp.