Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unordered_base: Fix compilation errors with CUDA backend #69

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/stdgpu/impl/unordered_base_detail.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ expected_collisions(const index_t bucket_count,
}


inline float
inline STDGPU_HOST_DEVICE float
default_max_load_factor()
{
return 1.0f;
Expand Down Expand Up @@ -357,6 +357,25 @@ occupied_count_valid(const unordered_base<Key, Value, KeyFromValue, Hash, KeyEqu
}


template <typename Key, typename Value, typename KeyFromValue, typename Hash, typename KeyEqual>
struct insert_value
{
unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual> base;

insert_value(const unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>& base)
: base(base)
{

}

STDGPU_DEVICE_ONLY void
operator()(const Value& value)
{
base.insert(value);
}
};


template <typename Key, typename Value, typename KeyFromValue, typename Hash, typename KeyEqual>
struct erase_from_key
{
Expand Down Expand Up @@ -808,8 +827,8 @@ inline void
unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::insert(device_ptr<unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::value_type> begin,
device_ptr<unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::value_type> end)
{
thrust::copy(begin, end,
stdgpu::inserter(*this));
thrust::for_each(begin, end,
insert_value<Key, Value, KeyFromValue, Hash, KeyEqual>(*this));
}


Expand All @@ -818,8 +837,8 @@ inline void
unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::insert(device_ptr<const unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::value_type> begin,
device_ptr<const unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::value_type> end)
{
thrust::copy(begin, end,
stdgpu::inserter(*this));
thrust::for_each(begin, end,
insert_value<Key, Value, KeyFromValue, Hash, KeyEqual>(*this));
}


Expand Down