Brick Library 0.1
Performance-portable stencil datalayout & codegen
Loading...
Searching...
No Matches
brickcompare.h
Go to the documentation of this file.
1
6#ifndef BRICK_BRICKCOMPARE_H
7#define BRICK_BRICKCOMPARE_H
8
9#include <iostream>
10#include <cmath>
11#include "bricksetup.h"
12#include "cmpconst.h"
13
14extern bool compareBrick_b;
15
16#pragma omp threadprivate(compareBrick_b)
17
30template<unsigned dims, typename T>
31inline bool
32compareBrick(const std::vector<long> &dimlist, const std::vector<long> &padding, const std::vector<long> &ghost,
33 bElem *arr, unsigned *grid_ptr, T &brick) {
34 bool ret = true;
35 auto f = [&ret](bElem &brick, const bElem *arr) -> void {
36 double diff = std::abs(brick - *arr);
37 bool r = (diff < BRICK_TOLERANCE) || (diff < (std::abs(brick) + std::abs(*arr)) * BRICK_TOLERANCE);
39 };
40
41#pragma omp parallel default(none)
42 {
43 compareBrick_b = true;
44 }
45
46 iter_grid<dims>(dimlist, padding, ghost, arr, grid_ptr, brick, f);
47
48#pragma omp parallel default(none) shared(ret)
49 {
50#pragma omp critical
51 {
52 ret = ret && compareBrick_b;
53 }
54 }
55
56 return ret;
57}
58
71template<unsigned dims, typename T>
72inline bool
73compareBrick(const std::vector<long> &dimlist, bElem *arr, unsigned *grid_ptr,
74 T &brick) {
75 std::vector<long> padding(dimlist.size(), 0);
76 std::vector<long> ghost(dimlist.size(), 0);
77
78 return compareBrick<dims, T>(dimlist, padding, ghost, arr, grid_ptr, brick);
79}
80
81#endif //BRICK_BRICKCOMPARE_H
bool compareBrick_b
Thread-private comparison accumulator.
Definition: brickcompare.cpp:3
bool compareBrick(const std::vector< long > &dimlist, const std::vector< long > &padding, const std::vector< long > &ghost, bElem *arr, unsigned *grid_ptr, T &brick)
Compare values between bricks and an array.
Definition: brickcompare.h:32
Brick iterator and setup code.
Tolerance for comparison.
#define BRICK_TOLERANCE
Definition: cmpconst.h:9
#define bElem
Basic datatype for all brick elements.
Definition: vecscatter.h:13
#define brick(...)
Inject stencil code for brick datalayout.
Definition: vecscatter.h:62