-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash.cu
557 lines (517 loc) · 23.2 KB
/
hash.cu
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
#pragma once
#include "base/types.hpp"
struct HashSummary {
std::string algorithm = "fnv";
index_t elements = 0;
int element_bytes = 0;
int element_offset = 0;
float k_tuples_p_seconds = 0.0;
float k_gb_p_seconds = 0.0;
void reset() {
algorithm = "fnv";
elements = 0;
element_offset = 0;
element_bytes = 0;
k_tuples_p_seconds = 0.0;
k_gb_p_seconds = 0.0;
}
};
struct HashConfig {
int threads_per_block = 256;
int elements_per_thread = 1;
std::string algorithm = "fnv";
cudaStream_t stream = 0;
bool profile_enabled = false;
cudaEvent_t profile_start, profile_end;
HashSummary profile_summary;
void enable_profile(cudaEvent_t profile_start, cudaEvent_t profile_end) {
this->profile_start = profile_start;
this->profile_end = profile_end;
profile_enabled = true;
}
void disbale_profile() {
profile_enabled = false;
}
};
__host__ __device__ constexpr hash_t get_fnv_prime() {
#if HASH_BITS == 32
return (uint32_t)(1 << 24) + (uint32_t)(1 << 8) + 0x93;
#elif HASH_BITS == 64
return (unsigned long long)(1ULL << 40) + (unsigned long long)(1 << 8) + 0xb3;
#endif
}
__host__ __device__ constexpr hash_t get_fnv_offset() {
#if HASH_BITS == 32
return 2166136261;
#elif HASH_BITS == 64
return 14695981039346656037;
#endif
}
__host__ __device__ constexpr unsigned short int get_max_shift() {
return (unsigned short int)(sizeof(hash_t) - sizeof(chunk_t) * 8) + 1;
}
__device__ inline hash_t reverse(hash_t hash) {
#if HASH_BITS == 64
return __brevll((unsigned long long)hash);
#elif HASH_BITS == 32
return __brev((uint)hash);
#endif
}
__device__ inline unsigned int permutate(unsigned int value, int shift) {
return __funnelshift_l(value, value, shift);
}
__host__ __device__ constexpr unsigned short int get_shift_increment() {
return sizeof(hash_t) > sizeof(uint);
}
__host__ __device__ constexpr int64_t get_max_value(unsigned short int bytes) {
return 1 << bytes * 8 - 1;
}
__global__ void hash_fnv(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
const hash_t FNV_prime = get_fnv_prime();
const hash_t FNV_offste_bias = get_fnv_offset();
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = FNV_offste_bias;
index_t buffer_index = element_index * element_chunks;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash ^= chunk;
hash *= FNV_prime;
#endif
#if HASH_CHUNK_BITS >= 32
hash ^= chunk.x;
hash *= FNV_prime;
#endif
#if HASH_CHUNK_BITS >= 64
hash ^= chunk.y;
hash *= FNV_prime;
#endif
#if HASH_CHUNK_BITS == 128
hash ^= chunk.z;
hash *= FNV_prime;
hash ^= chunk.w;
hash *= FNV_prime;
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_add(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash += ((hash_t)chunk);
#endif
#if HASH_CHUNK_BITS >= 32
hash += ((hash_t)chunk.x);
#endif
#if HASH_CHUNK_BITS >= 64
hash += ((hash_t)chunk.y);
#endif
#if HASH_CHUNK_BITS == 128
hash += ((hash_t)chunk.z);
hash += ((hash_t)chunk.w);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_add_shift(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash_offset = (hash_offset + chunk) % get_max_shift();
hash += ((hash_t)chunk) << hash_offset;
#endif
#if HASH_CHUNK_BITS >= 32
hash_offset = (hash_offset + chunk.x) % get_max_shift();
hash += ((hash_t)chunk.x) << hash_offset;
#endif
#if HASH_CHUNK_BITS >= 64
hash_offset = (hash_offset + chunk.y) % get_max_shift();
hash += ((hash_t)chunk.y) << hash_offset;
#endif
#if HASH_CHUNK_BITS == 128
hash_offset = (hash_offset + chunk.z) % get_max_shift();
hash += ((hash_t)chunk.z) << hash_offset;
hash_offset = (hash_offset + chunk.w) % get_max_shift();
hash += ((hash_t)chunk.w) << hash_offset;
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_add_hw(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
int shift = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash += (hash_t)permutate(chunk, shift++);
#endif
#if HASH_CHUNK_BITS >= 32
hash += (hash_t)permutate(chunk.x, shift++);
#endif
#if HASH_CHUNK_BITS >= 64
hash += (hash_t)permutate(chunk.y, shift++);
#endif
#if HASH_CHUNK_BITS == 128
hash += (hash_t)permutate(chunk.z, shift++);
hash += (hash_t)permutate(chunk.w, shift++);
#endif
hash = reverse(hash);
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_xor(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash ^= ((hash_t)chunk);
#endif
#if HASH_CHUNK_BITS >= 32
hash ^= ((hash_t)chunk.x);
#endif
#if HASH_CHUNK_BITS >= 64
hash ^= ((hash_t)chunk.y);
#endif
#if HASH_CHUNK_BITS == 128
hash ^= ((hash_t)chunk.z);
hash ^= ((hash_t)chunk.w);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_xor_shift(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash_offset = (hash_offset + chunk) % get_max_shift();
hash ^= ((hash_t)chunk) << hash_offset;
#endif
#if HASH_CHUNK_BITS >= 32
hash_offset = (hash_offset + chunk.x) % get_max_shift();
hash ^= ((hash_t)chunk.x) << hash_offset;
#endif
#if HASH_CHUNK_BITS >= 64
hash_offset = (hash_offset + chunk.y) % get_max_shift();
hash ^= ((hash_t)chunk.y) << hash_offset;
#endif
#if HASH_CHUNK_BITS == 128
hash_offset = (hash_offset + chunk.z) % get_max_shift();
hash ^= ((hash_t)chunk.z) << hash_offset;
hash_offset = (hash_offset + chunk.w) % get_max_shift();
hash ^= ((hash_t)chunk.w) << hash_offset;
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_xor_hw(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
uint32_t shift = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
shift += chunk;
hash ^= (hash_t)permutate(chunk, shift);
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS >= 32
shift += chunk.x;
hash ^= (hash_t)permutate(chunk.x, shift);
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS >= 64
shift += chunk.y;
hash ^= (hash_t)permutate(chunk.y, shift);
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS == 128
shift += chunk.z;
hash ^= (hash_t)permutate(chunk.z, shift);
hash = reverse(hash);
shift += chunk.w;
hash ^= (hash_t)permutate(chunk.w, shift);
hash = reverse(hash);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_mult(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 1;
index_t buffer_index = element_index * element_chunks;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash = 1 + (hash * ((hash_t)chunk + 1));
#endif
#if HASH_CHUNK_BITS >= 32
hash = 1 + (hash * ((hash_t)chunk.x + 1));
#endif
#if HASH_CHUNK_BITS >= 64
hash = 1 + (hash * ((hash_t)chunk.y + 1));
#endif
#if HASH_CHUNK_BITS == 128
hash = 1 + (hash * ((hash_t)chunk.z + 1));
hash = 1 + (hash * ((hash_t)chunk.w + 1));
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_mult_shift(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 1;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
hash_offset = (hash_offset + chunk) % get_max_shift();
hash = 1 + (hash * ((hash_t)chunk + 1) << hash_offset);
#endif
#if HASH_CHUNK_BITS >= 32
hash_offset = (hash_offset + chunk.x) % get_max_shift();
hash = 1 + (hash * ((hash_t)chunk.x + 1) << hash_offset);
#endif
#if HASH_CHUNK_BITS >= 64
hash_offset = (hash_offset + chunk.y) % get_max_shift();
hash = 1 + (hash * ((hash_t)chunk.y + 1) << hash_offset);
#endif
#if HASH_CHUNK_BITS == 128
hash_offset = (hash_offset + chunk.z) % get_max_shift();
hash = 1 + (hash * ((hash_t)chunk.z + 1) << hash_offset);
hash_offset = (hash_offset + chunk.w) % get_max_shift();
hash = 1 + (hash * ((hash_t)chunk.w + 1) << hash_offset);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_mult_hw(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 1;
index_t buffer_index = element_index * element_chunks;
int shift = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
shift += chunk;
hash = 1 + (hash * ((hash_t)permutate(chunk, shift) + 1));
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS >= 32
shift += chunk.x;
hash = 1 + (hash * ((hash_t)permutate(chunk.x, shift) + 1));
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS >= 64
shift += chunk.y;
hash = 1 + (hash * ((hash_t)permutate(chunk.y, shift) + 1));
hash = reverse(hash);
#endif
#if HASH_CHUNK_BITS == 128
shift += chunk.z;
hash = 1 + (hash * ((hash_t)permutate(chunk.z, shift) + 1));
hash = reverse(hash);
shift += chunk.w;
hash = 1 + (hash * ((hash_t)permutate(chunk.w, shift) + 1));
hash = reverse(hash);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__device__ inline void mult_xor_shift(hash_t &hash, hash_t chunk, short int &operation, short int &hash_offset) {
hash_offset = (hash_offset + chunk) % get_max_shift();
if (operation & 1) {
hash = 1 + (hash * ((hash_t)(chunk + 1) << hash_offset));
} else {
hash = (hash ^ ((hash_t)chunk << hash_offset));
}
operation++;
}
__device__ inline void mult_xor_hw(hash_t &hash, hash_t chunk, short int &operation, short int &hash_offset) {
if (operation & 1) {
hash = 1 + (hash * ((hash_t)permutate(chunk + 1, hash_offset)));
} else {
hash = (hash ^ ((hash_t)permutate(chunk, hash_offset)));
}
operation++;
hash_offset += chunk;
hash = reverse(hash);
}
__global__ void hash_custom_mult_xor_shift(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
short int operation = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
mult_xor_shift(hash, chunk, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 32
mult_xor_shift(hash, chunk.x, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 64
mult_xor_shift(hash, chunk.y, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS == 128
mult_xor_shift(hash, chunk.z, operation, hash_offset);
mult_xor_shift(hash, chunk.w, operation, hash_offset);
#endif
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_n_mult_xor_shift(index_t element_buffer_size, short int chunk_offset, short int element_chunks, short int rounds, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
short int operation = 0;
for (short int round_index = 0; round_index < rounds; round_index++) {
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
mult_xor_shift(hash, chunk, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 32
mult_xor_shift(hash, chunk.x, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 64
mult_xor_shift(hash, chunk.y, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS == 128
mult_xor_shift(hash, chunk.z, operation, hash_offset);
mult_xor_shift(hash, chunk.w, operation, hash_offset);
#endif
}
}
hashed_buffer[element_index] = hash;
}
}
__global__ void hash_custom_mult_xor_hw(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (index_t element_index = index; element_index < element_buffer_size; element_index += stride) {
hash_t hash = 0;
index_t buffer_index = element_index * element_chunks;
short int hash_offset = 0;
short int operation = 0;
for (short int chunk_index = chunk_offset; chunk_index < element_chunks; chunk_index++) {
chunk_t chunk = element_buffer[buffer_index + chunk_index];
#if HASH_CHUNK_BITS == 8
mult_xor_hw(hash, chunk, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 32
mult_xor_hw(hash, chunk.x, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS >= 64
mult_xor_hw(hash, chunk.y, operation, hash_offset);
#endif
#if HASH_CHUNK_BITS == 128
mult_xor_hw(hash, chunk.z, operation, hash_offset);
mult_xor_hw(hash, chunk.w, operation, hash_offset);
#endif
}
hashed_buffer[element_index] = hash;
}
}
void hash_func(index_t element_buffer_size, short int chunk_offset, short int element_chunks, chunk_t *element_buffer, hash_t *hashed_buffer, HashConfig &hash_config) {
int threads = hash_config.threads_per_block;
int blocks = max((element_buffer_size / hash_config.elements_per_thread) / threads, (index_t)1);
if (hash_config.profile_enabled) {
cudaEventRecord(hash_config.profile_start, hash_config.stream);
}
if (hash_config.algorithm == "fnv") {
hash_fnv<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_xor") {
hash_custom_xor<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_xor_shift") {
hash_custom_xor_shift<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_xor_hw") {
hash_custom_xor_hw<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_mult_xor_shift") {
hash_custom_mult_xor_shift<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_n_mult_xor_shift") {
hash_custom_n_mult_xor_shift<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, 2, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_mult_xor_hw") {
hash_custom_mult_xor_hw<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_mult") {
hash_custom_mult<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_mult_shift") {
hash_custom_mult_shift<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_mult_hw") {
hash_custom_mult_hw<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_add") {
hash_custom_add<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_add_shift") {
hash_custom_add_shift<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
} else if (hash_config.algorithm == "custom_add_hw") {
hash_custom_add_hw<<<blocks, threads, 0, hash_config.stream>>>(element_buffer_size, chunk_offset, element_chunks, element_buffer, hashed_buffer);
}
if (hash_config.profile_enabled) {
cudaEventRecord(hash_config.profile_end, hash_config.stream);
float runtime_ms = 0.0;
cudaEventSynchronize(hash_config.profile_end);
cudaEventElapsedTime(&runtime_ms, hash_config.profile_start, hash_config.profile_end);
float runtime_s = runtime_ms / pow(10, 3);
hash_config.profile_summary.k_tuples_p_seconds = element_buffer_size / runtime_s;
int element_size = (element_chunks - chunk_offset) * sizeof(chunk_t);
hash_config.profile_summary.k_gb_p_seconds = element_size * element_buffer_size / runtime_s / pow(10, 9);
hash_config.profile_summary.algorithm = hash_config.algorithm;
hash_config.profile_summary.elements = element_buffer_size;
hash_config.profile_summary.element_bytes = element_chunks * sizeof(chunk_t);
hash_config.profile_summary.element_offset = chunk_offset * sizeof(chunk_t);
}
}