Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
findpts_el_3_test2.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <math.h>
5 #include <float.h>
6 #include <string.h>
7 #include "c99.h"
8 #include "types.h"
9 #include "name.h"
10 #include "fail.h"
11 #include "mem.h"
12 #include "tensor.h"
13 #include "poly.h"
14 #include "lob_bnd.h"
15 #include "obbox.h"
16 #include "findpts_el.h"
17 #include "rand_elt_test.h"
18 #include "rdtsc.h"
19 
20 #define USE_HW_COUNTER 1
21 
22 #if USE_HW_COUNTER
24 #endif
25 
26 #define REPEAT 100
27 
28 #define NR 7
29 #define TNR 8
30 #define NS 8
31 #define TNS 9
32 #define NT 9
33 #define TNT 7
34 #define TNTOT (TNR*TNS*TNT)
35 #define MR (4*NR)
36 #define MS (4*NS)
37 #define MT (4*NT)
38 
39 static const unsigned nr[3] = {NR,NS,NT};
40 
41 /* #define NPT 1 */
42 #define NPT 256
43 /* #define NPT TNR*TNS*TNT */
44 
45 #define TOL 1024*DBL_EPSILON
46 
47 static double zr[NR], zs[NS], zt[NT];
48 static double tzr[TNR], tzs[TNS], tzt[TNT];
49 static double Jr[NR*TNR],Js[NS*TNS],Jt[NT*TNT];
50 static double elx[NR*NS*NT], ely[NR*NS*NT], elz[NR*NS*NT];
51 static const double *const elxyz[3] = {elx,ely,elz};
52 static double telx[3][TNR*TNS*TNT];
53 static double work[TNR*(NS+TNS)*NT];
54 
55 int main()
56 {
57  int failure=0;
58  unsigned n,i,ie;
59 
60 #if USE_HW_COUNTER
61  unsigned long long tic,toc, tot=0;
62 #else
63  int unconv=0;
64 #endif
65 
66  struct findpts_el_data_3 fd;
67  struct findpts_el_pt_3 *pt;
68  findpts_el_setup_3(&fd,nr,NPT);
69  pt = findpts_el_points_3(&fd);
70 
73 
74  for(i=0;i<TNR;++i) fd.lag[0](Jr+i*NR, fd.lag_data[0], NR, 0, tzr[i]);
75  for(i=0;i<TNS;++i) fd.lag[1](Js+i*NS, fd.lag_data[1], NS, 0, tzs[i]);
76  for(i=0;i<TNT;++i) fd.lag[2](Jt+i*NT, fd.lag_data[2], NT, 0, tzt[i]);
77  for(n=0;n<6+REPEAT;++n) {
78  if(n<6)
79  bubble_elt(elx,ely,elz, zr,NR, zs,NS, zt,NT, n);
80  else
81  rand_elt_3(elx,ely,elz, zr,NR, zs,NS, zt,NT);
82  tensor_3t(telx[0], Jr,TNR,NR, Js,TNS,NS, Jt,TNT,NT, elx, work);
83  tensor_3t(telx[1], Jr,TNR,NR, Js,TNS,NS, Jt,TNT,NT, ely, work);
84  tensor_3t(telx[2], Jr,TNR,NR, Js,TNS,NS, Jt,TNT,NT, elz, work);
85 #if USE_HW_COUNTER
86  tic = getticks();
87 #endif
88  findpts_el_start_3(&fd, elxyz);
89  for(i=0;i<TNTOT;) {
90  unsigned i0=i;
91  ie = i+NPT, ie = ie>TNTOT ? TNTOT : ie;
92  for(;i!=ie;++i) {
93  struct findpts_el_pt_3 *p = pt+(i-i0);
94  const double x=telx[0][i],y=telx[1][i],z=telx[2][i];
95  p->x[0]=x,p->x[1]=y,p->x[2]=z;
96  p->flags = 0;
97  }
98  findpts_el_3(&fd, ie-i0, 1024*DBL_EPSILON);
99 #if !(USE_HW_COUNTER)
100  for(i=i0;i!=ie;++i) {
101  struct findpts_el_pt_3 *p = pt+(i-i0);
102  const double r=tzr[i%TNR], s=tzs[(i/TNR)%TNS], t=tzt[i/(TNR*TNS)];
103  if((p->flags&(1u<<6))==0) ++unconv;
104  if(fabs(p->r[0]-r)+fabs(p->r[1]-s)+fabs(p->r[2]-t)>1024*DBL_EPSILON) {
105  printf("found (%g,%g,%g) for (%g,%g,%g) ; error (%g,%g,%g)\n",
106  p->r[0],p->r[1],p->r[2], r,s,t, p->r[0]-r,p->r[1]-s,p->r[2]-t);
107  printf("(%g,%g,%g) for (%.15g,%.15g,%.15g) ; dist2 = %g\n",
108  p->x[0],p->x[1],p->x[2],
109  telx[0][i],telx[1][i],telx[2][i],p->dist2);
110  ++failure;
111  }
112  }
113 #endif
114  }
115 #if USE_HW_COUNTER
116  toc = getticks();
117  printf("element took %llu cycles\n",toc-tic);
118  tot+=toc-tic;
119 #endif
120  }
121 
122  findpts_el_free_3(&fd);
123 
124 #if !(USE_HW_COUNTER)
125  printf("%u failed points (out of %u)\n", failure, (6+REPEAT)*TNTOT);
126  printf("%u unconverged points\n", unconv);
127 #else
128  printf("average cycles = %g\n", tot/(double)(6+REPEAT));
129 #endif
130 
131  return failure;
132 }
static double Jr[NR *TNR]
double r[3]
Definition: findpts_el.h:69
#define TNTOT
static double zt[NT]
lagrange_fun * lag[3]
Definition: findpts_el.h:84
static double ely[NR *NS *NT]
void bubble_elt(double *x, double *y, double *z, const double *zr, unsigned nr, const double *zs, unsigned ns, const double *zt, unsigned nt, int type)
#define findpts_el_3
Definition: findpts_el.h:65
n
Definition: xxt_test.m:73
static double zr[NR]
static struct findpts_el_pt_3 * findpts_el_points_3(struct findpts_el_data_3 *const fd)
Definition: findpts_el.h:116
int main()
#define x
static const double *const elxyz[3]
#define TNT
static const unsigned nr[3]
#define NS
#define NR
#define REPEAT
void rand_elt_3(double *x, double *y, double *z, const double *zr, unsigned nr, const double *zs, unsigned ns, const double *zt, unsigned nt)
p
Definition: xxt_test2.m:1
#define findpts_el_free_3
Definition: findpts_el.h:64
#define NPT
static double tzs[TNS]
#define DEFINE_HW_COUNTER()
Definition: rdtsc.h:4
static double work[TNR *(NS+TNS)*NT]
static double zs[NS]
#define findpts_el_setup_3
Definition: findpts_el.h:63
double * lag_data[3]
Definition: findpts_el.h:85
static void findpts_el_start_3(struct findpts_el_data_3 *const fd, const double *const x[3])
Definition: findpts_el.h:110
for i
Definition: xxt_test.m:74
unsigned flags
Definition: findpts_el.h:70
static double Js[NS *TNS]
static double tzt[TNT]
static double tzr[TNR]
static double elx[NR *NS *NT]
static double elz[NR *NS *NT]
#define TNR
double x[3]
Definition: findpts_el.h:69
static void tensor_3t(double *out, const double *Jrt, uint nr, uint mr, const double *Jst, uint ns, uint ms, const double *Jtt, uint nt, uint mt, const double *u, double *work)
Definition: tensor.h:183
#define lobatto_nodes
Definition: poly.c:15
establishes some macros to establish naming conventions
#define NT
#define TNS
static double y[NR *NS *NT *N]
Definition: obbox_test.c:31
static double Jt[NT *TNT]
static double telx[3][TNR *TNS *TNT]
static double z[NR *NS *NT *N]
Definition: obbox_test.c:31