-
Notifications
You must be signed in to change notification settings - Fork 99
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
HashmapAccumulator has several unused members, misnamed parameters #508
Comments
I'll mark this cleanup enhancement since this isn't a bug |
@brian-kelley: Although removing kokkos-kernels/src/common/KokkosKernels_HashmapAccumulator.hpp Lines 442 to 502 in 750fe24
kokkos-kernels/src/sparse/impl/KokkosSparse_spgemm_impl_speed.hpp Lines 433 to 444 in 750fe24
This same use-case is making completely removing |
Keep in mind this is used at the very low level. Performance of this data structure is important for the performance of the kernels. |
Thanks, Siva. What are the reasons for calculating the hash outside of the inlined HashmapAccumulator insertion routines? |
I don't see a particular use case for that. |
I mean, we are currently calculating the hash outside of the inlined HashmapAccumulator insertion routines. Why are we doing this? |
@e10harvey I guess you could make |
Thanks @brian-kelley. This is exactly what I've started. |
@brian-kelley: Actually, thinking about this more, is there any reason against adding the following to the constructor bodies: compute_hash_func = compute_hash_func_table[__hash_op]; Then the instertion routines will invoke: hash = compute_hash_func(arg1, arg2); |
@e10harvey Function pointers/first-class functions incur overhead on CPUs and I don't think they can be used at all in CUDA. I would just go with the template. |
Actually function pointers are supported in all CUDA versions supported by Kokkos, but they still have a performance cost. |
The HashmapAccumulator has three members (
hash_key_size
,max_value_size
, andused_size
) that are not used internally, but they are set by the constructors.used_size_
andmax_value_size_
(with trailing underscores) are instead passed to the insert() routines.hash_key_size_
is not passed to any insert routines. It is the number of possible hash outputs, aka 1 plus the bit mask that forms the hash function:hash(value) = value & (hash_key_size - 1)
.I think these changes would make sense and make things a lot more readable and debuggable:
max_value_size
is the length of thekeys
andnexts
arrays, so it should be an immutable member.max_value_size_
should not be passed into the insert routines. In fact, what SPGEMM symbolic does now is read out the member from the hashmap and pass it in.max_value_size
should really be calledcapacity
or something similar - it's meaning is the length of the two arrays (keys, nexts).used_size
is an atomically incremented counter that measures how full the hashmap is. It is updated in parallel, so it usually lives in shared/global memory. It should either not be a member and just be passed by ref to insert, OR kept as a member, but be a pointer.hash_key_size
:KOKKOS_FORCEINLINE_FUNCTION key_type hash()
be a member of Hashmap. The SPGEMM code wouldn't need to keep the hash mask as a local variable anymore.The text was updated successfully, but these errors were encountered: