Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jun 19, 2023
1 parent feaa4a3 commit abae018
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
29 changes: 18 additions & 11 deletions src/common/column_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,16 @@ class DenseColumnIter : public Column<BinIdxT> {
};

/**
* \brief Column major matrix for gradient index. This matrix contains both dense column
* and sparse column, the type of the column is controlled by sparse threshold. When the
* number of missing values in a column is below the threshold it's classified as dense
* column.
* @brief Column major matrix for gradient index on CPU.
*
* This matrix contains both dense columns and sparse columns, the type of the column
* is controlled by the sparse threshold parameter. When the number of missing values
* in a column is below the threshold it's classified as dense column.
*/
class ColumnMatrix {
/**
* @brief A bit set for indicating whether an element in a dense column is missing.
*/
struct MissingIndicator {
LBitField32 missing;
RefResourceView<std::uint32_t> storage;
Expand All @@ -159,8 +163,9 @@ class ColumnMatrix {
storage = common::MakeFixedVecWithMalloc(m_size, init ? ~std::uint32_t{0} : std::uint32_t{0});
InitView();
}
void Clear(typename LBitField32::index_type i) { missing.Clear(i); }

/** @brief Set the i^th element to be a valid element (instead of missing). */
void SetValid(typename LBitField32::index_type i) { missing.Clear(i); }
/** @brief assign the storage to the view. */
void InitView() { missing = LBitField32{Span{storage.data(), storage.size()}}; }
};

Expand All @@ -174,7 +179,7 @@ class ColumnMatrix {
// not thread-safe with bool vector.
// FIXME(jiamingy): We can directly assign kMissingId to the index to avoid missing
// flags.
missing_.Clear(feature_offsets_[fid] + rid);
missing_.SetValid(feature_offsets_[fid] + rid);
} else {
ColumnBinT* begin = &local_index[feature_offsets_[fid]];
begin[num_nonzeros_[fid]] = bin_id - index_base_[fid];
Expand All @@ -186,15 +191,17 @@ class ColumnMatrix {
public:
using ByteType = bool;
// get number of features
[[nodiscard]] bst_feature_t GetNumFeature() const { return static_cast<bst_feature_t>(type_.size()); }
[[nodiscard]] bst_feature_t GetNumFeature() const {
return static_cast<bst_feature_t>(type_.size());
}

ColumnMatrix() = default;
ColumnMatrix(GHistIndexMatrix const& gmat, double sparse_threshold) {
this->InitStorage(gmat, sparse_threshold);
}

/**
* \brief Initialize ColumnMatrix from GHistIndexMatrix with reference to the original
* @brief Initialize ColumnMatrix from GHistIndexMatrix with reference to the original
* SparsePage.
*/
void InitFromSparse(SparsePage const& page, const GHistIndexMatrix& gmat, double sparse_threshold,
Expand All @@ -206,8 +213,8 @@ class ColumnMatrix {
}

/**
* \brief Initialize ColumnMatrix from GHistIndexMatrix without reference to actual
* data.
* @brief Initialize ColumnMatrix from GHistIndexMatrix without reference to actual
* data.
*
* This function requires a binary search for each bin to get back the feature index
* for those bins.
Expand Down
3 changes: 3 additions & 0 deletions src/common/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ std::string FileExtension(std::string fname, bool lower) {
}
}

// For some reason, NVCC 12.1 marks the function deleted if we expose it in the header.
ResourceHandler::~ResourceHandler() noexcept(false) = default;

struct MMAPFile {
#if defined(xgboost_IS_WIN)
HANDLE fd{INVALID_HANDLE_VALUE};
Expand Down
6 changes: 4 additions & 2 deletions src/common/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#include <dmlc/io.h>
#include <rabit/rabit.h>

#include <cstddef> // for byte, size_t
#include <algorithm> // for min
#include <cstddef> // for byte, size_t
#include <cstring>
#include <fstream>
#include <limits> // for numeric_limits
#include <memory> // for unique_ptr
#include <string> // for string
#include <utility> // for move
Expand Down Expand Up @@ -145,7 +147,7 @@ class ResourceHandler {

[[nodiscard]] virtual std::size_t Size() const = 0;
// Allow exceptions for cleaning up resource.
virtual ~ResourceHandler() noexcept(false){};
virtual ~ResourceHandler() noexcept(false);

ResourceHandler() = default;
// Use shared_ptr to manage a pool like resource handler. All copy and assignment
Expand Down

0 comments on commit abae018

Please sign in to comment.