Skip to content

Commit 5a3f4b5

Browse files
committed
Tidy's happy.
1 parent 449d2e4 commit 5a3f4b5

37 files changed

+209
-214
lines changed

.clang-tidy

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
Checks: 'modernize-*,-modernize-make-*,-modernize-use-auto,-modernize-raw-string-literal,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,google-*,-google-default-arguments,-clang-diagnostic-#pragma-messages,readability-identifier-naming'
22
CheckOptions:
3-
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
4-
- { key: readability-identifier-naming.StructCase, value: CamelCase }
5-
- { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
6-
- { key: readability-identifier-naming.TypedefCase, value: CamelCase }
7-
- { key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase }
8-
- { key: readability-identifier-naming.MemberCase, value: lower_case }
9-
- { key: readability-identifier-naming.PrivateMemberSuffix, value: '_' }
10-
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: '_' }
11-
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
12-
- { key: readability-identifier-naming.EnumConstant, value: CamelCase }
13-
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
14-
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
15-
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
16-
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
17-
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
18-
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
19-
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
20-
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
21-
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
3+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
4+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
5+
- { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
6+
- { key: readability-identifier-naming.TypedefCase, value: CamelCase }
7+
- { key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase }
8+
- { key: readability-identifier-naming.MemberCase, value: lower_case }
9+
- { key: readability-identifier-naming.PrivateMemberSuffix, value: '_' }
10+
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: '_' }
11+
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
12+
- { key: readability-identifier-naming.EnumConstant, value: CamelCase }
13+
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
14+
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
15+
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
16+
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
17+
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
18+
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
19+
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
20+
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
21+
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }

include/xgboost/span.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class SpanIterator {
137137
IsConst, const ElementType, ElementType>::type&;
138138
using pointer = typename std::add_pointer<reference>::type; // NOLINT
139139

140-
XGBOOST_DEVICE constexpr SpanIterator() : span_{nullptr}, index_{0} {} // NOLINT
140+
constexpr SpanIterator() = default;
141141

142142
XGBOOST_DEVICE constexpr SpanIterator(
143143
const SpanType* _span,
@@ -410,8 +410,7 @@ class Span {
410410
using const_reverse_iterator = const detail::SpanIterator<Span<T, Extent>, true>; // NOLINT
411411

412412
// constructors
413-
414-
XGBOOST_DEVICE constexpr Span() __span_noexcept : size_(0), data_(nullptr) {} // NOLINT
413+
constexpr Span() __span_noexcept = default;
415414

416415
XGBOOST_DEVICE Span(pointer _ptr, index_type _count) :
417416
size_(_count), data_(_ptr) {

src/common/bitfield.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ struct BitFieldContainer {
8686
XGBOOST_DEVICE explicit BitFieldContainer(common::Span<value_type> bits) : bits_{bits} {}
8787
XGBOOST_DEVICE BitFieldContainer(BitFieldContainer const& other) : bits_{other.bits_} {}
8888

89-
common::Span<value_type> Bits() { return bits_; };
90-
common::Span<value_type const> Bits() const { return bits_; };
89+
common::Span<value_type> Bits() { return bits_; }
90+
common::Span<value_type const> Bits() const { return bits_; }
9191

9292
/*\brief Compute the size of needed memory allocation. The returned value is in terms
9393
* of number of elements with `BitFieldContainer::value_type'.

src/common/device_helpers.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ template <typename FunctionT, typename SegmentIterT, typename OffsetT>
868868
void SparseTransformLbs(int device_idx, dh::CubMemory *temp_memory,
869869
OffsetT count, SegmentIterT segments,
870870
OffsetT num_segments, FunctionT f) {
871-
typedef typename cub::CubVector<OffsetT, 2>::Type CoordinateT;
871+
using CoordinateT = typename cub::CubVector<OffsetT, 2>::Type;
872872
dh::safe_cuda(cudaSetDevice(device_idx));
873873
const int BLOCK_THREADS = 256;
874874
const int ITEMS_PER_THREAD = 1;

src/common/hist_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ struct Index {
293293
return reinterpret_cast<uint32_t*>(t)[i];
294294
}
295295

296-
using Func = uint32_t (*)(void* ,size_t);
296+
using Func = uint32_t (*)(void*, size_t);
297297

298298
std::vector<uint8_t> data_;
299299
std::vector<uint32_t> offset_; // size of this field is equal to number of features
300300
void* data_ptr_;
301-
BinTypeSize binTypeSize_;
302-
size_t p_;
303-
uint32_t* offset_ptr_;
301+
BinTypeSize binTypeSize_ {kUint8BinsTypeSize};
302+
size_t p_ {1};
303+
uint32_t* offset_ptr_ {nullptr};
304304
Func func_;
305305
};
306306

src/common/row_set.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class RowSetCollection {
9090
elem_of_each_node_.emplace_back(Elem(begin, end, 0));
9191
}
9292

93-
std::vector<size_t>* Data() { return &row_indices_; };
93+
std::vector<size_t>* Data() { return &row_indices_; }
9494
// split rowset into two
9595
inline void AddSplit(unsigned node_id,
9696
unsigned left_node_id,

src/common/transform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ class Transform {
133133
template <typename std::enable_if<CompiledWithCuda>::type* = nullptr,
134134
typename... HDV>
135135
void LaunchCUDA(Functor _func, HDV*... _vectors) const {
136-
if (shard_)
136+
if (shard_) {
137137
UnpackShard(device_, _vectors...);
138+
}
138139

139140
size_t range_size = *range_.end() - *range_.begin();
140141

src/data/ellpack_page.cuh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class EllpackPageImpl {
185185
base_rowid = row_id;
186186
}
187187

188+
common::HistogramCuts& Cuts() { return cuts_; }
189+
common::HistogramCuts const& Cuts() const { return cuts_; }
190+
188191
/*! \return Estimation of memory cost of this page. */
189192
static size_t MemCostBytes(size_t num_rows, size_t row_stride, const common::HistogramCuts&cuts) ;
190193

@@ -220,8 +223,9 @@ public:
220223
size_t n_rows{};
221224
/*! \brief global index of histogram, which is stored in ELLPack format. */
222225
HostDeviceVector<common::CompressedByteT> gidx_buffer;
226+
227+
private:
223228
common::HistogramCuts cuts_;
224-
private:
225229
common::Monitor monitor_;
226230
};
227231

src/data/ellpack_page_raw_format.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class EllpackPageRawFormat : public SparsePageFormat<EllpackPage> {
1717
public:
1818
bool Read(EllpackPage* page, dmlc::SeekStream* fi) override {
1919
auto* impl = page->Impl();
20-
fi->Read(&impl->cuts_.cut_values_.HostVector());
21-
fi->Read(&impl->cuts_.cut_ptrs_.HostVector());
22-
fi->Read(&impl->cuts_.min_vals_.HostVector());
20+
fi->Read(&impl->Cuts().cut_values_.HostVector());
21+
fi->Read(&impl->Cuts().cut_ptrs_.HostVector());
22+
fi->Read(&impl->Cuts().min_vals_.HostVector());
2323
fi->Read(&impl->n_rows);
2424
fi->Read(&impl->is_dense);
2525
fi->Read(&impl->row_stride);
@@ -38,9 +38,9 @@ class EllpackPageRawFormat : public SparsePageFormat<EllpackPage> {
3838

3939
void Write(const EllpackPage& page, dmlc::Stream* fo) override {
4040
auto* impl = page.Impl();
41-
fo->Write(impl->cuts_.cut_values_.ConstHostVector());
42-
fo->Write(impl->cuts_.cut_ptrs_.ConstHostVector());
43-
fo->Write(impl->cuts_.min_vals_.ConstHostVector());
41+
fo->Write(impl->Cuts().cut_values_.ConstHostVector());
42+
fo->Write(impl->Cuts().cut_ptrs_.ConstHostVector());
43+
fo->Write(impl->Cuts().min_vals_.ConstHostVector());
4444
fo->Write(impl->n_rows);
4545
fo->Write(impl->is_dense);
4646
fo->Write(impl->row_stride);

src/metric/elementwise_metric.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ struct EvalEWiseBase : public Metric {
350350
}
351351

352352
private:
353-
Policy policy_ {};
353+
Policy policy_;
354354
ElementWiseMetricsReduction<Policy> reducer_{policy_};
355355
};
356356

src/metric/metric_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PackedReduceResult {
6666
double weights_sum_ { 0 };
6767

6868
public:
69-
XGBOOST_DEVICE PackedReduceResult() : residue_sum_{0}, weights_sum_{0} {} // NOLINT
69+
XGBOOST_DEVICE PackedReduceResult() {} // NOLINT
7070
XGBOOST_DEVICE PackedReduceResult(double residue, double weight)
7171
: residue_sum_{residue}, weights_sum_{weight} {}
7272

src/tree/gpu_hist/gradient_based_sampler.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ExternalMemoryNoSampling::ExternalMemoryNoSampling(EllpackPageImpl* page,
153153
size_t n_rows,
154154
const BatchParam& batch_param)
155155
: batch_param_(batch_param),
156-
page_(new EllpackPageImpl(batch_param.gpu_id, page->cuts_, page->is_dense,
156+
page_(new EllpackPageImpl(batch_param.gpu_id, page->Cuts(), page->is_dense,
157157
page->row_stride, n_rows)) {}
158158

159159
GradientBasedSample ExternalMemoryNoSampling::Sample(common::Span<GradientPair> gpair,
@@ -218,7 +218,7 @@ GradientBasedSample ExternalMemoryUniformSampling::Sample(common::Span<GradientP
218218
// Create a new ELLPACK page with empty rows.
219219
page_.reset(); // Release the device memory first before reallocating
220220
page_.reset(new EllpackPageImpl(
221-
batch_param_.gpu_id, original_page_->cuts_, original_page_->is_dense,
221+
batch_param_.gpu_id, original_page_->Cuts(), original_page_->is_dense,
222222
original_page_->row_stride, sample_rows));
223223

224224
// Compact the ELLPACK pages into the single sample page.
@@ -298,7 +298,7 @@ GradientBasedSample ExternalMemoryGradientBasedSampling::Sample(common::Span<Gra
298298

299299
// Create a new ELLPACK page with empty rows.
300300
page_.reset(); // Release the device memory first before reallocating
301-
page_.reset(new EllpackPageImpl(batch_param_.gpu_id, original_page_->cuts_,
301+
page_.reset(new EllpackPageImpl(batch_param_.gpu_id, original_page_->Cuts(),
302302
original_page_->is_dense,
303303
original_page_->row_stride, sample_rows));
304304

src/tree/gpu_hist/row_partitioner.cu

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -64,54 +64,55 @@ void RowPartitioner::SortPosition(common::Span<bst_node_t> position,
6464
cub::DeviceScan::ExclusiveSum(temp_storage.data().get(), temp_storage_bytes,
6565
in_itr, out_itr, position.size(), stream);
6666
}
67+
6768
RowPartitioner::RowPartitioner(int device_idx, size_t num_rows)
68-
: device_idx(device_idx) {
69-
dh::safe_cuda(cudaSetDevice(device_idx));
70-
ridx_a.resize(num_rows);
71-
ridx_b.resize(num_rows);
72-
position_a.resize(num_rows);
73-
position_b.resize(num_rows);
74-
ridx = dh::DoubleBuffer<RowIndexT>{&ridx_a, &ridx_b};
75-
position = dh::DoubleBuffer<bst_node_t>{&position_a, &position_b};
76-
ridx_segments.emplace_back(Segment(0, num_rows));
69+
: device_idx_(device_idx) {
70+
dh::safe_cuda(cudaSetDevice(device_idx_));
71+
ridx_a_.resize(num_rows);
72+
ridx_b_.resize(num_rows);
73+
position_a_.resize(num_rows);
74+
position_b_.resize(num_rows);
75+
ridx_ = dh::DoubleBuffer<RowIndexT>{&ridx_a_, &ridx_b_};
76+
position_ = dh::DoubleBuffer<bst_node_t>{&position_a_, &position_b_};
77+
ridx_segments_.emplace_back(Segment(0, num_rows));
7778

7879
thrust::sequence(
79-
thrust::device_pointer_cast(ridx.CurrentSpan().data()),
80-
thrust::device_pointer_cast(ridx.CurrentSpan().data() + ridx.Size()));
80+
thrust::device_pointer_cast(ridx_.CurrentSpan().data()),
81+
thrust::device_pointer_cast(ridx_.CurrentSpan().data() + ridx_.Size()));
8182
thrust::fill(
82-
thrust::device_pointer_cast(position.Current()),
83-
thrust::device_pointer_cast(position.Current() + position.Size()), 0);
84-
left_counts.resize(256);
85-
thrust::fill(left_counts.begin(), left_counts.end(), 0);
86-
streams.resize(2);
87-
for (auto& stream : streams) {
83+
thrust::device_pointer_cast(position_.Current()),
84+
thrust::device_pointer_cast(position_.Current() + position_.Size()), 0);
85+
left_counts_.resize(256);
86+
thrust::fill(left_counts_.begin(), left_counts_.end(), 0);
87+
streams_.resize(2);
88+
for (auto& stream : streams_) {
8889
dh::safe_cuda(cudaStreamCreate(&stream));
8990
}
9091
}
9192
RowPartitioner::~RowPartitioner() {
92-
dh::safe_cuda(cudaSetDevice(device_idx));
93-
for (auto& stream : streams) {
93+
dh::safe_cuda(cudaSetDevice(device_idx_));
94+
for (auto& stream : streams_) {
9495
dh::safe_cuda(cudaStreamDestroy(stream));
9596
}
9697
}
9798

9899
common::Span<const RowPartitioner::RowIndexT> RowPartitioner::GetRows(
99100
bst_node_t nidx) {
100-
auto segment = ridx_segments.at(nidx);
101+
auto segment = ridx_segments_.at(nidx);
101102
// Return empty span here as a valid result
102103
// Will error if we try to construct a span from a pointer with size 0
103104
if (segment.Size() == 0) {
104105
return common::Span<const RowPartitioner::RowIndexT>();
105106
}
106-
return ridx.CurrentSpan().subspan(segment.begin, segment.Size());
107+
return ridx_.CurrentSpan().subspan(segment.begin, segment.Size());
107108
}
108109

109110
common::Span<const RowPartitioner::RowIndexT> RowPartitioner::GetRows() {
110-
return ridx.CurrentSpan();
111+
return ridx_.CurrentSpan();
111112
}
112113

113114
common::Span<const bst_node_t> RowPartitioner::GetPosition() {
114-
return position.CurrentSpan();
115+
return position_.CurrentSpan();
115116
}
116117
std::vector<RowPartitioner::RowIndexT> RowPartitioner::GetRowsHost(
117118
bst_node_t nidx) {
@@ -135,22 +136,22 @@ void RowPartitioner::SortPositionAndCopy(const Segment& segment,
135136
cudaStream_t stream) {
136137
SortPosition(
137138
// position_in
138-
common::Span<bst_node_t>(position.Current() + segment.begin,
139+
common::Span<bst_node_t>(position_.Current() + segment.begin,
139140
segment.Size()),
140141
// position_out
141-
common::Span<bst_node_t>(position.Other() + segment.begin,
142+
common::Span<bst_node_t>(position_.Other() + segment.begin,
142143
segment.Size()),
143144
// row index in
144-
common::Span<RowIndexT>(ridx.Current() + segment.begin, segment.Size()),
145+
common::Span<RowIndexT>(ridx_.Current() + segment.begin, segment.Size()),
145146
// row index out
146-
common::Span<RowIndexT>(ridx.Other() + segment.begin, segment.Size()),
147+
common::Span<RowIndexT>(ridx_.Other() + segment.begin, segment.Size()),
147148
left_nidx, right_nidx, d_left_count, stream);
148149
// Copy back key/value
149-
const auto d_position_current = position.Current() + segment.begin;
150-
const auto d_position_other = position.Other() + segment.begin;
151-
const auto d_ridx_current = ridx.Current() + segment.begin;
152-
const auto d_ridx_other = ridx.Other() + segment.begin;
153-
dh::LaunchN(device_idx, segment.Size(), stream, [=] __device__(size_t idx) {
150+
const auto d_position_current = position_.Current() + segment.begin;
151+
const auto d_position_other = position_.Other() + segment.begin;
152+
const auto d_ridx_current = ridx_.Current() + segment.begin;
153+
const auto d_ridx_other = ridx_.Other() + segment.begin;
154+
dh::LaunchN(device_idx_, segment.Size(), stream, [=] __device__(size_t idx) {
154155
d_position_current[idx] = d_position_other[idx];
155156
d_ridx_current[idx] = d_ridx_other[idx];
156157
});

0 commit comments

Comments
 (0)