Skip to content

The static_map of custom type becomes very slow after modifying the custom_key_equal function. #558

Answered by PointKernel
Po1sson asked this question in Q&A
Discussion options

You must be logged in to vote
auto pairs_begin = thrust::make_transform_iterator(
thrust::make_counting_iterator<int32_t>(0),
cuda::proclaim_return_type<cuco::pair<custom_key_type, custom_value_type>>(
[] __device__(auto i) {
return cuco::pair{ custom_key_type{i%100,i}, custom_value_type{i} };
}));

By doing so, you are adding more duplicates to the input. Thus more hash collisions. To solve the problem, you may want to update your hash function accordingly to minimize collisions, e.g.

// User-defined device hash callable
struct custom_hash {
    __device__ uint32_t operator()(custom_key_type const& k) const noexcept { return k.a + k.b; };
};

Or hash your struct properly like https://stackoverflow.com/questions/1919518…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@Po1sson
Comment options

@Po1sson
Comment options

Answer selected by Po1sson
Comment options

You must be logged in to vote
2 replies
@Po1sson
Comment options

@Po1sson
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
topic: static_map Issue related to the static_map topic: performance Performance related issue
3 participants