Skip to content

Commit

Permalink
Merge pull request #4 from kstppd/fixes_premerge
Browse files Browse the repository at this point in the history
Fixes premerge
  • Loading branch information
markusbattarbee authored May 30, 2024
2 parents 2cc5a48 + 1fafa6e commit cbb899a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 66 deletions.
31 changes: 16 additions & 15 deletions include/hashinator/hashinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* */
#pragma once
#include <cstddef>
#ifdef HASHINATOR_CPU_ONLY_MODE
#define SPLIT_CPU_ONLY_MODE
#endif
Expand Down Expand Up @@ -84,7 +85,7 @@ class Hashmap {
void preallocate_device_handles() {
#ifndef HASHINATOR_CPU_ONLY_MODE
SPLIT_CHECK_ERR(split_gpuMalloc((void**)&device_map, sizeof(Hashmap)));
device_buckets = (split::SplitVector<hash_pair<KEY_TYPE, VAL_TYPE>>*)((char*)device_map + offsetof(Hashmap, buckets));
device_buckets=reinterpret_cast<split::SplitVector<hash_pair<KEY_TYPE, VAL_TYPE>>*>(reinterpret_cast<char*>(device_map)+offsetof(Hashmap,buckets));
#endif
}

Expand Down Expand Up @@ -289,7 +290,7 @@ class Hashmap {
hash_pair<KEY_TYPE, VAL_TYPE>* validElements;
SPLIT_CHECK_ERR(split_gpuMallocAsync((void**)&validElements,
(_mapInfo->fill + 1) * sizeof(hash_pair<KEY_TYPE, VAL_TYPE>), s));
if (prefetches) {
if constexpr (prefetches) {
optimizeGPU(s);
SPLIT_CHECK_ERR(split_gpuStreamSynchronize(s));
}
Expand Down Expand Up @@ -477,7 +478,7 @@ class Hashmap {
break;

case targets::device:
if (prefetches) {
if constexpr(prefetches) {
optimizeGPU(s);
}
if (len==0) { // If size is provided, no need to page fault size information.
Expand Down Expand Up @@ -1127,7 +1128,7 @@ class Hashmap {
size_t extractPattern(split::SplitVector<hash_pair<KEY_TYPE, VAL_TYPE>>& elements, Rule rule,
split_gpuStream_t s = 0) {
elements.resize(_mapInfo->fill + 1, true);
if (prefetches) {
if constexpr(prefetches) {
elements.optimizeGPU(s);
}
// Extract elements matching the Pattern Rule(element)==true;
Expand Down Expand Up @@ -1172,23 +1173,23 @@ class Hashmap {
template <bool prefetches = true, typename Rule>
size_t extractKeysByPattern(split::SplitVector<KEY_TYPE>& elements, Rule rule, split_gpuStream_t s = 0) {
elements.resize(_mapInfo->fill + 1, true);
if (prefetches) {
if constexpr(prefetches) {
elements.optimizeGPU(s);
}
// Extract element **keys** matching the Pattern Rule(element)==true;
split::tools::copy_keys_if<hash_pair<KEY_TYPE, VAL_TYPE>, KEY_TYPE, Rule, defaults::MAX_BLOCKSIZE,
defaults::WARPSIZE>(buckets, elements, rule, s);
//FIXME: there is an issue where paging to host occurs and following calls to hashmap operations take a hit.
//temp fix: call optimizeGPU() here
if (prefetches) {
if constexpr (prefetches) {
optimizeGPU(s);
}
return elements.size();
}
template <bool prefetches = true, typename Rule>
size_t extractKeysByPattern(split::SplitVector<KEY_TYPE>& elements, Rule rule, void *stack, size_t max_size, split_gpuStream_t s = 0) {
elements.resize(_mapInfo->fill + 1, true);
if (prefetches) {
if constexpr(prefetches) {
elements.optimizeGPU(s);
}
// Extract element **keys** matching the Pattern Rule(element)==true;
Expand Down Expand Up @@ -1243,7 +1244,7 @@ class Hashmap {
SPLIT_CHECK_ERR(split_gpuMallocAsync((void**)&overflownElements,
(1 << _mapInfo->sizePower) * sizeof(hash_pair<KEY_TYPE, VAL_TYPE>), s));

if (prefetches) {
if constexpr(prefetches) {
optimizeGPU(s);
}
SPLIT_CHECK_ERR(split_gpuStreamSynchronize(s));
Expand Down Expand Up @@ -1294,7 +1295,7 @@ class Hashmap {
set_status(status::success);
return;
}
if (prefetches) {
if constexpr(prefetches) {
buckets.optimizeGPU(s);
}
int64_t neededPowerSize = std::ceil(std::log2((_mapInfo->fill + len) * (1.0 / targetLF)));
Expand All @@ -1316,7 +1317,7 @@ class Hashmap {
set_status(status::success);
return;
}
if (prefetches) {
if constexpr(prefetches) {
buckets.optimizeGPU(s);
}
int64_t neededPowerSize = std::ceil(std::log2((_mapInfo->fill + len) * (1.0 / targetLF)));
Expand All @@ -1336,7 +1337,7 @@ class Hashmap {
set_status(status::success);
return;
}
if (prefetches) {
if constexpr(prefetches) {
buckets.optimizeGPU(s);
}
// Here we do some calculations to estimate how much if any we need to grow our buckets
Expand All @@ -1352,7 +1353,7 @@ class Hashmap {
// Uses Hasher's retrieve_kernel to read all elements
template <bool prefetches = true>
void retrieve(KEY_TYPE* keys, VAL_TYPE* vals, size_t len, split_gpuStream_t s = 0) {
if (prefetches){
if constexpr(prefetches){
buckets.optimizeGPU(s);
}
DeviceHasher::retrieve(keys, vals, buckets.data(), _mapInfo->sizePower, _mapInfo->currentMaxBucketOverflow, len,
Expand All @@ -1363,7 +1364,7 @@ class Hashmap {
// Uses Hasher's retrieve_kernel to read all elements
template <bool prefetches = true>
void retrieve(hash_pair<KEY_TYPE, VAL_TYPE>* src, size_t len, split_gpuStream_t s = 0) {
if (prefetches){
if constexpr(prefetches){
buckets.optimizeGPU(s);
}
DeviceHasher::retrieve(src, buckets.data(), _mapInfo->sizePower, _mapInfo->currentMaxBucketOverflow, len, s);
Expand All @@ -1373,7 +1374,7 @@ class Hashmap {
// Uses Hasher's erase_kernel to delete all elements
template <bool prefetches = true>
void erase(KEY_TYPE* keys, size_t len, split_gpuStream_t s = 0) {
if (prefetches){
if constexpr(prefetches){
buckets.optimizeGPU(s);
}
// Remember the last numeber of tombstones
Expand All @@ -1393,7 +1394,7 @@ class Hashmap {
*/
template <bool prefetches = true>
Hashmap* upload(split_gpuStream_t stream = 0) {
if (prefetches) {
if constexpr(prefetches) {
optimizeGPU(stream);
}
// device_buckets = (split::SplitVector<hash_pair<KEY_TYPE, VAL_TYPE>>*)((char*)device_map + offsetof(Hashmap, buckets));
Expand Down
Loading

0 comments on commit cbb899a

Please sign in to comment.