Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 2af1398

Browse files
committed
naive tbb
1 parent 29b5456 commit 2af1398

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

omniscidb/QueryEngine/JoinHashTable/Runtime/HashJoinRuntime.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ DEVICE int SUFFIX(fill_hash_join_buff_bucketized_cpu)(
350350
const int32_t* sd_inner_to_outer_translation_map,
351351
const int32_t min_inner_elem,
352352
const int64_t bucket_normalization) {
353-
int partial_err = 0;
354353
auto filling_func = for_semi_join ? SUFFIX(fill_hashtable_for_semi_join)
355354
: SUFFIX(fill_one_to_one_hashtable);
356355
auto hashtable_filling_func = [&](int64_t elem, size_t index) {
@@ -366,13 +365,14 @@ DEVICE int SUFFIX(fill_hash_join_buff_bucketized_cpu)(
366365
reinterpret_cast<const struct JoinChunk*>(join_column.col_chunks_buff);
367366
// BTW it's vector with sz:
368367
// join_column.num_chunks
369-
const int8_t* chunk_mem_ptr = join_chunk_array->col_buff;
370-
size_t global_elem_index = 0;
368+
// const int8_t* chunk_mem_ptr = join_chunk_array->col_buff;
369+
371370
// LOG(ERROR) << "fill_hash_join_buff_cpu chunk buff size: "
372371
// << join_column.col_chunks_buff_sz << " num elems: " <<
373372
// join_column.num_elems
374373
// << " num_chunks: " << join_column.num_chunks;
375-
374+
std::atomic<int> err{0};
375+
std::atomic<size_t> global_elem_index{0};
376376
tbb::parallel_for(
377377
tbb::blocked_range<size_t>(0, join_column.num_chunks),
378378
[&](const tbb::blocked_range<size_t>& join_chunks_range) {
@@ -395,7 +395,8 @@ DEVICE int SUFFIX(fill_hash_join_buff_bucketized_cpu)(
395395
for (size_t elem_i = curr_chnunk_elems_range.begin();
396396
elem_i != curr_chnunk_elems_range.end();
397397
elem_i++) {
398-
chunk_mem_ptr = curr_chunk.col_buff;
398+
int partial_err = 0;
399+
const int8_t* chunk_mem_ptr = curr_chunk.col_buff;
399400

400401
// char line[1024];
401402
// snprintf(line, sizeof(line), " ptr: %p", chunk_mem_ptr);
@@ -477,20 +478,28 @@ DEVICE int SUFFIX(fill_hash_join_buff_bucketized_cpu)(
477478
// chunk_i
478479
// << " el_i: " << elem_i;
479480

480-
if (hashtable_filling_func(elem, global_elem_index)) {
481+
if (hashtable_filling_func(elem, global_elem_index.load())) {
481482
partial_err = -1;
482483
}
483484

484485
global_elem_index++;
485486
if (partial_err != 0) {
486487
// LOG(ERROR) << "error here! " << partial_err;
487-
return partial_err;
488+
int zero{0};
489+
err.compare_exchange_strong(zero, partial_err);
490+
break;
488491
}
489492
partial_err = 0;
490493
}
491494
});
495+
if (err) {
496+
break;
497+
}
492498
}
493499
});
500+
if (err) {
501+
return -1;
502+
}
494503
return 0;
495504
}
496505
#endif

0 commit comments

Comments
 (0)