Clang-tidy static analysis (#3222)
* Clang-tidy static analysis * Modernise checks * Google coding standard checks * Identifier renaming according to Google style
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
// dummy implementation of HostDeviceVector in case CUDA is not used
|
||||
|
||||
#include <xgboost/base.h>
|
||||
|
||||
#include <utility>
|
||||
#include "./host_device_vector.h"
|
||||
|
||||
namespace xgboost {
|
||||
@@ -13,8 +15,8 @@ namespace xgboost {
|
||||
template <typename T>
|
||||
struct HostDeviceVectorImpl {
|
||||
explicit HostDeviceVectorImpl(size_t size, T v) : data_h_(size, v) {}
|
||||
explicit HostDeviceVectorImpl(std::initializer_list<T> init) : data_h_(init) {}
|
||||
explicit HostDeviceVectorImpl(const std::vector<T>& init) : data_h_(init) {}
|
||||
HostDeviceVectorImpl(std::initializer_list<T> init) : data_h_(init) {}
|
||||
explicit HostDeviceVectorImpl(std::vector<T> init) : data_h_(std::move(init)) {}
|
||||
std::vector<T> data_h_;
|
||||
};
|
||||
|
||||
@@ -43,25 +45,25 @@ HostDeviceVector<T>::~HostDeviceVector() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t HostDeviceVector<T>::size() const { return impl_->data_h_.size(); }
|
||||
size_t HostDeviceVector<T>::Size() const { return impl_->data_h_.size(); }
|
||||
|
||||
template <typename T>
|
||||
int HostDeviceVector<T>::device() const { return -1; }
|
||||
int HostDeviceVector<T>::DeviceIdx() const { return -1; }
|
||||
|
||||
template <typename T>
|
||||
T* HostDeviceVector<T>::ptr_d(int device) { return nullptr; }
|
||||
T* HostDeviceVector<T>::DevicePointer(int device) { return nullptr; }
|
||||
|
||||
template <typename T>
|
||||
std::vector<T>& HostDeviceVector<T>::data_h() { return impl_->data_h_; }
|
||||
std::vector<T>& HostDeviceVector<T>::HostVector() { return impl_->data_h_; }
|
||||
|
||||
template <typename T>
|
||||
void HostDeviceVector<T>::resize(size_t new_size, T v, int new_device) {
|
||||
void HostDeviceVector<T>::Resize(size_t new_size, T v, int new_device) {
|
||||
impl_->data_h_.resize(new_size, v);
|
||||
}
|
||||
|
||||
// explicit instantiations are required, as HostDeviceVector isn't header-only
|
||||
template class HostDeviceVector<bst_float>;
|
||||
template class HostDeviceVector<bst_gpair>;
|
||||
template class HostDeviceVector<GradientPair>;
|
||||
|
||||
} // namespace xgboost
|
||||
|
||||
|
||||
Reference in New Issue
Block a user