Make all headers self-contained#141
Conversation
|
rerun tests |
sleeepyjack
left a comment
There was a problem hiding this comment.
Thanks @PointKernel for this PR! I made some comments targeting the automation of some reoccurring tasks regarding the code structure. This would also cause fewer diffs in future PRs. Happy to hear your thoughts on this.
| #include <synchronization.hpp> | ||
|
|
||
| #include <cuco/dynamic_map.cuh> | ||
|
|
||
| #include <benchmark/benchmark.h> | ||
|
|
||
| #include <iostream> | ||
| #include <random> |
There was a problem hiding this comment.
This seems to be a permutation of the same includes. I think clang_format is already sorting these in lexicographic order for us if they are defined in a contiguous block, which is nice and consistent. However, lexicographic order might not always be correct or desired. Maybe we can customize the clang_format file to always produce an ordering that satisfies our needs and then just let the CI take care of it.
There was a problem hiding this comment.
The idea here is to separate different header groups and order them from "near" to "far". e.g. synchronization.hpp is a bench-local header thus it's placed before the library header cuco/dynamic_map.cuh. gbench header is even further but considered closer than std headers.
This grouping method seems a bit awkward with only one file in each group but will show its advantage with more headers involved.
There was a problem hiding this comment.
Ah ok, this makes sense. I wonder however if we should add a CI script for that. Basically extract all includes, check in the include tree where this file originates, group and then reorder.
| #include <cuco/detail/pair.cuh> | ||
| #include <cub/cub.cuh> | ||
|
|
||
| #include <cuda/std/atomic> |
There was a problem hiding this comment.
We access the atomic types through a typedef atomicT, so we don't need to include <cuda/std/atomic> here... At least I think that's the case.
There was a problem hiding this comment.
It's still needed due to atomic operations like this:
Removing it will cause build failure:
/home/yunsongw/Work/cuCollections/include/cuco/detail/static_multimap/kernels.cuh(256): error: name followed by "::" must be a class or namespace name
detected during instantiation of "std::size_t cuco::static_multimap<Key, Value, Scope, Allocator, ProbeSequence>::count_outer(InputIt, InputIt, cudaStream_t, KeyEqual) const [with Key=int, Value=int, Scope=cuda::std::__4::__detail::thread_scope_device, Allocator=cuco::cuda_allocator<char>, ProbeSequence=cuco::double_hashing<8U, cuco::detail::MurmurHash3_32<int>, cuco::detail::MurmurHash3_32<int>>, InputIt=thrust::detail::normal_iterator<thrust::device_ptr<int>>, KeyEqual=thrust::equal_to<int>]"
There was a problem hiding this comment.
Yes but in L242 we call view.count() which is also not declared (only after the template is instantiated).
Closes #140
This PR reorders header groups in
cucoand add missing headers to make sure all headers are self-contained.To be merged after #155 and #156.