1#ifndef HASH_PAIR_BUILDER_PERIODIC_PARALLEL_H
2#define HASH_PAIR_BUILDER_PERIODIC_PARALLEL_H
18 template<
class Pred,
class OP>
25 std::cout <<
"We use parallel hash pair builder ****************************" <<
std::endl;
33 parallel_dims[0] = !(globDomain[0]==locDomain[0]);
34 parallel_dims[1] = !(globDomain[1]==locDomain[1]);
35 parallel_dims[2] = !(globDomain[2]==locDomain[2]);
38 period=extend_r-extend_l;
45 for (
unsigned dim = 0; dim<3; ++dim)
53 dmsg <<
" period = " << period <<
endl;
59 std::size_t *buckets =
new size_t[Nbucket];
60 std::size_t *next =
new size_t[size];
61 std::fill(buckets, buckets+Nbucket, END);
62 std::fill(next, next+size, END);
67 int offset[14][3] = {{ 1, 1, 1}, { 0, 1, 1}, {-1, 1, 1},
68 { 1, 0, 1}, { 0, 0, 1}, {-1, 0, 1},
69 { 1,-1, 1}, { 0,-1, 1}, {-1,-1, 1},
70 { 1, 1, 0}, { 0, 1, 0}, {-1, 1, 0},
71 { 1, 0, 0}, { 0, 0, 0}};
74 for(std::size_t i = 0;i<size;++i)
77 next[i] = buckets[bucket_id];
78 buckets[bucket_id] = i;
81 double part_count = 0;
83 for (
int bx=0+
int(!parallel_dims[0]); bx<
buckets_per_dim[0]-int(!parallel_dims[0]); ++bx) {
84 for (
int by=0+
int(!parallel_dims[1]); by<
buckets_per_dim[1]-int(!parallel_dims[1]); ++by) {
85 for (
int bz=0+
int(!parallel_dims[2]); bz<
buckets_per_dim[2]-int(!parallel_dims[2]); ++bz) {
88 for (
unsigned n=0;
n<neigh;++
n){
89 int bx_neigh, by_neigh, bz_neigh;
92 bx_neigh = bx+offset[
n][0];
94 if (!parallel_dims[0]) {
98 shift[0] = -period[0];
103 shift[0] = period[0];
107 by_neigh = by+offset[
n][1];
108 if (!parallel_dims[1]) {
111 shift[1] = -period[0];
115 shift[1] = period[1];
119 bz_neigh = bz+offset[
n][2];
120 if (!parallel_dims[2]) {
123 shift[2] = -period[2];
127 shift[2] = period[2];
135 unsigned bucket_id_neigh =
139 std::size_t i = buckets[bucket_id_self];
148 j = buckets[bucket_id_neigh];
150 for (
int o=0;o<self_offset;o++){
163 if (bucket_id_self==bucket_id_neigh)
185 for (
unsigned d=0; d<3; ++d)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Vektor< double, 3 > rmax_m
int get_bucket_id(int i, const Pred &)
HashPairBuilderPeriodicParallel(PBase &p)
Vektor< double, 3 > h_chaining
Vektor< int, 3 > buckets_per_dim
void for_each(const Pred &pred, const OP &op, Vektor< double, 3 > extend_l, Vektor< double, 3 > extend_r)
PBase::Position_t Position_t
Vektor< double, 3 > rmin_m
int get_bucket_id(int i, const Pred &pred)