This repository was archived by the owner on Dec 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
409 lines (344 loc) · 10.2 KB
/
Copy pathutils.h
File metadata and controls
409 lines (344 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#include <cstring>
#include <iostream>
#include <bitset>
using namespace std;
#include <immintrin.h>
#include <unistd.h>
#include <fstream>
#include <string>
#include <sstream>
#include <string>
#include "r_tree/rtree0.h"
#include "r_tree/rtree00.h"
#include "r_tree/rtree000.h"
#include "r_tree/rtree0000.h"
#include "r_tree/rtree128.h"
#include "r_tree/rtree256.h"
#include "r_tree/rtree512.h"
#include "r_tree/rtree1024.h"
#include "r_tree/rtree2048.h"
#include "r_tree/rtree4096.h"
// #include "r_tree/rtree1.h"
// #include "r_tree/rtree11.h"
// #include "r_tree/rtree111.h"
// #include "r_tree/rtree1111.h"
// #include "r_tree/rtree2.h"
#include "r_tree/rtree16_d1.h"
#include "r_tree/rtree32_d1.h"
#include "r_tree/rtree64_d1.h"
#include "r_tree/rtree128_d1.h"
#include "r_tree/rtree256_d1.h"
#include "r_tree/rtree512_d1.h"
#include "r_tree/rtree1024_d1.h"
#include "r_tree/rtree2048_d1.h"
#include "commonMethod.cpp"
#include "omp.h"
#include <chrono>
#include <queue>
#include <random>
#include <thread>
#include "PerfEvent.hpp"
#include <inttypes.h>
#include <iomanip>
#define XDEBUG 1
string fix( float x, int p )
{
ostringstream strout ;
strout << fixed << setprecision(p) << x ;
string str = strout.str() ;
size_t end = str.find_last_not_of( '0' ) + 1 ;
return str.erase( end ) ;
}
void print_nl(){
if (XDEBUG == 1) cout << endl;
}
void print_int(int x){
if (XDEBUG == 1) cout << x << endl;
}
void print128_num(__m128 var)
{
float val[4];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %f %f %f %f \n", val[0], val[1], val[2], val[3]);
}
}
void print256_num(__m256 var)
{
float val[8];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %f %f %f %f %f %f %f %f \n",
val[0], val[1], val[2], val[3], val[4], val[5],
val[6], val[7]);
}
}
void print256d_num(__m256d var)
{
double val[4];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %f %f %f %f\n",
val[0], val[1], val[2], val[3]);
}
}
void print256d_addr(__m256d var)
{
tnode16* val[4];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %p %p %p %p\n",
val[0], val[1], val[2], val[3]);
}
}
// void print128i_num64(__m128i var)
// {
// uint64_t val[2];
// memcpy(val, &var, sizeof(val));
// if (XDEBUG == 1)
// {
// printf("Numerical: %"PRId64" %"PRId64"\n",
// val[0], val[1]
// );
// }
// }
void print256i_num(__m256i var)
{
int val[8];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %d %d %d %d %d %d %d %d \n",
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]
);
}
}
// void print256i_num_64(__m256i var)
// {
// uint64_t val[4];
// memcpy(val, &var, sizeof(val));
// if (XDEBUG == 1)
// {
// printf("Numerical: %"PRId64" %"PRId64" %"PRId64" %"PRId64"\n",
// val[0], val[1], val[2], val[3]
// );
// }
// }
void print512d_addr(__m512d var)
{
tnode128* val[8];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %p %p %p %p %p %p %p %p\n",
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
}
}
void print512i_num(__m512i var)
{
int val[16];
memcpy(val, &var, sizeof(val));
if (XDEBUG == 1)
{
printf("Numerical: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n",
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7],
val[8], val[9], val[10], val[11], val[12], val[13], val[14], val[15]);
}
}
void print512_num(__m512 var)
{
float val[16];
memcpy(val, &var, sizeof(val));
if(XDEBUG == 1)
{
printf("Numerical: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n",
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7],
val[8], val[9], val[10], val[11], val[12], val[13], val[14], val[15]);
}
}
void print8_mask(__mmask8 mask){
int val = _cvtmask8_u32(mask);
bitset<8> bs(val);
for (size_t i = 0; i < bs.size(); ++i) {
if (XDEBUG == 1) cout << bs[i] << " " ;
}
if (XDEBUG == 1) cout << endl;
}
void print16_mask(__mmask16 mask){
int val = _mm512_mask2int (mask);
bitset<16> bs(val);
for (size_t i = 0; i < bs.size(); ++i) {
if (XDEBUG == 1) cout << bs[i] << " " ;
}
if (XDEBUG == 1) cout << endl;
}
void print32_mask(__mmask32 mask){
int val = _cvtmask32_u32(mask);
bitset<32> bs(val);
for (size_t i = 0; i < bs.size(); ++i) {
if (XDEBUG == 1) cout << bs[i] << " " ;
}
if (XDEBUG == 1) cout << endl;
}
void print64_mask(__mmask64 mask){
uint64_t val = _cvtmask64_u64(mask);
bitset<64> bs(val);
for (size_t i = 0; i < bs.size(); ++i) {
if (XDEBUG == 1) cout << bs[i] << " " ;
}
if (XDEBUG == 1) cout << endl;
}
bool IsBitSet(int num, int bit)
{
int y = (num >> bit) & 3;
// bitset<64> bitset1(y);
// if (XDEBUG == 1) cout << bitset1 << endl;
return 0 == ( (num >> bit) & 3);
}
bool is_bit_set_mask(__mmask16 mask, int bit)
{
int num = _mm512_mask2int(mask);
return 1 == ( (num >> bit) & 1);
}
void print_bitset16(bitset<16> bs){
if(XDEBUG == 1)
cout << bs << endl;
}
__mmask16 lshift_mask16(__mmask16 mask, int count){
__mmask16 inactive_lane;
if (count == 0) inactive_lane = _kshiftli_mask16(mask, 0);
else if (count == 2) inactive_lane = _kshiftli_mask16(mask, 2);
else if (count == 4) inactive_lane = _kshiftli_mask16(mask, 4);
else if (count == 6) inactive_lane = _kshiftli_mask16(mask, 6);
else if (count == 8) inactive_lane = _kshiftli_mask16(mask, 8);
else if (count == 10) inactive_lane = _kshiftli_mask16(mask, 10);
else if (count == 12) inactive_lane = _kshiftli_mask16(mask, 12);
else if (count == 14) inactive_lane = _kshiftli_mask16(mask, 14);
else if (count == 16) inactive_lane = _kshiftli_mask16(mask, 16);
return inactive_lane;
}
class rec{
public:
float lx;
float ly;
float hx;
float hy;
void create_rec(float lx, float ly, float hx, float hy)
{
this->lx = lx;
this->ly = ly;
this->hx = hx;
this->hy = hy;
}
float area(){
if (this->lx >= this->hx || this->ly >= this->hy)
return 0;
return (
(this->hx - this->lx)*(this->hx - this->lx) +
(this->hy - this->ly)*(this->hy - this->ly)
);
}
};
class point{
public:
float px;
float py;
void create_pt(float px, float py)
{
this->px = px;
this->py = py;
}
};
// For flushing caches
const int num_nodes_int = 7135;
tnode1024 tree_int[num_nodes_int];
int fan_out_int = 1024;
void build_tree_int(string version);
void compute_task_int(tnode1024 *n1);
void build_tree_int(string version){
string room_file = "/home/yrayhan/numa-aware_simd_search/data/join/" + version + ".txt";
ifstream rtree_reader(room_file.c_str());
if (XDEBUG == 1) cout << "At least started creating" << endl;
commonMethod cm;
if (!rtree_reader)
{
cout << "no dataset!";
}
else
{
string line;
int cnt = 0;
while (getline(rtree_reader, line))
{
vector<string> info = cm.split(line, " ");
tnode1024 n;
int count_child;
vector<float> lx;
vector<float> ly;
vector<float> hx;
vector<float> hy;
vector<int> child_id;
int level;
int id;
count_child = atoi(info[0].c_str());
size_t start = 2;
size_t end = start + count_child;
for(size_t i = start; i < end; i++)
{
lx.push_back(atoi(info[i].c_str()));
}
// if(XDEBUG == 1) cout << "CHECK POINT lx" << endl;
for(size_t i= start + count_child; i <= end + count_child; i++)
{
ly.push_back(atoi(info[i].c_str()));
}
// if(XDEBUG == 1) cout << "CHECK POINT ly" << endl;
for(size_t i = start + 2*count_child; i <= end + 2*count_child; i++)
{
hx.push_back(atoi(info[i].c_str()));
}
// if(XDEBUG == 1) cout << "CHECK POINT hx" << endl;
for(size_t i = start + 3*count_child; i <= end + 3*count_child; i++)
{
hy.push_back(atoi(info[i].c_str()));
}
// if(XDEBUG == 1) cout << "CHECK POINT hy" << endl;
for(size_t i = start + 4*count_child; i <= end + 4*count_child; i++)
{
child_id.push_back(atoi(info[i].c_str()));
}
// if(XDEBUG == 1) cout << "CHECK POINT CID" << endl;
level = atoi(info[5*count_child+2].c_str());
id = atoi(info[5*count_child+3].c_str());
// if(XDEBUG == 1) cout << "CHECK POINT CID" << endl;
n.create_node(count_child, lx, ly, hx, hy, level, id);
// if(XDEBUG == 1) n.print_node();
// if(XDEBUG == 1) cout << "CHECK POINT CREATE NODE" << endl;
tree_int[id] = n;
for(size_t i =0; i < count_child; i++){
tree_int[id].ptr[i] = &tree_int[child_id[i]];
}
// if(XDEBUG == 1) cout << "CHECK POINT PTR" << endl;
// if(XDEBUG == 1) cout << "IDX: " << cnt << endl;
// cnt++;
// if(i / 8 == 0){
// tree[id].ptr1[i] = &tree[child_id[i]];
// }
// else{
// tree[id].ptr2[i%8] = &tree[child_id[i]];
// }
}
}
}
void compute_task_int(tnode1024 *n1){
for (int i = 0; i < 1024; i+= 16){
__m512 mbr_c1 = _mm512_load_ps (n1->low_x + i);
__m512 mbr_c2 = _mm512_load_ps (n1->low_y + i);
__m512 mbr_c3 = _mm512_load_ps (n1->high_x + i);
__m512 mbr_c4 = _mm512_load_ps (n1->high_y + i);
}
}