From 2e618af743091644395b2be066633951651b9827 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Mon, 18 Feb 2019 00:16:29 +0800 Subject: [PATCH] Fix cpplint. (#4157) * Add comment after #endif. * Add missing headers. --- R-package/src/init.c | 6 +++--- R-package/src/xgboost_custom.cc | 2 +- cmake/build_config.h.in | 4 ++++ include/xgboost/base.h | 18 +++++++++--------- include/xgboost/build_config.h | 2 +- include/xgboost/c_api.h | 9 +++++---- include/xgboost/learner.h | 1 + include/xgboost/logging.h | 12 ++++++------ include/xgboost/predictor.h | 3 +++ src/common/common.cc | 2 +- src/common/common.h | 4 ++-- src/common/compressed_iterator.h | 4 ++-- src/common/hist_util.cc | 6 +++--- src/common/host_device_vector.cc | 2 +- src/common/host_device_vector.h | 7 ++++--- src/common/math.h | 4 ++-- src/common/random.h | 2 +- src/common/span.h | 6 +++--- src/common/timer.h | 4 ++-- src/common/transform.h | 7 ++++--- src/data/data.cc | 6 +++--- src/data/simple_dmatrix.h | 4 ++++ src/data/sparse_page_dmatrix.cc | 2 +- src/data/sparse_page_dmatrix.h | 2 ++ src/data/sparse_page_source.cc | 4 ++-- src/data/sparse_page_source.h | 5 ++++- src/data/sparse_page_writer.h | 2 +- src/gbm/gbtree_model.h | 2 ++ src/learner.cc | 4 ++-- src/linear/linear_updater.cc | 2 +- src/logging.cc | 2 +- src/metric/elementwise_metric.cc | 2 +- src/metric/elementwise_metric.cu | 4 ++-- src/objective/hinge.cc | 2 +- src/objective/hinge.cu | 2 +- src/objective/multiclass_obj.cc | 2 +- src/objective/multiclass_obj.cu | 2 +- src/objective/objective.cc | 2 +- src/objective/regression_obj.cc | 2 +- src/objective/regression_obj.cu | 2 +- src/predictor/predictor.cc | 2 +- src/tree/split_evaluator.cc | 1 + src/tree/split_evaluator.h | 1 + src/tree/tree_updater.cc | 2 +- src/tree/updater_colmaker.cc | 2 +- src/tree/updater_quantile_hist.h | 1 + 46 files changed, 97 insertions(+), 72 deletions(-) diff --git a/R-package/src/init.c b/R-package/src/init.c index bd493a2af223..1020d279e34a 100644 --- a/R-package/src/init.c +++ b/R-package/src/init.c @@ -1,5 +1,5 @@ /* Copyright (c) 2015 by Contributors - * + * * This file was initially generated using the following R command: * tools::package_native_routine_registration_skeleton('.', con = 'src/init.c', character_only = F) * and edited to conform to xgboost C linter requirements. For details, see @@ -10,7 +10,7 @@ #include #include -/* FIXME: +/* FIXME: Check these declarations against the C/Fortran source code. */ @@ -70,7 +70,7 @@ static const R_CallMethodDef CallEntries[] = { #if defined(_WIN32) __declspec(dllexport) -#endif +#endif // defined(_WIN32) void R_init_xgboost(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); diff --git a/R-package/src/xgboost_custom.cc b/R-package/src/xgboost_custom.cc index 8b6ee2a7f168..8a169f2dcbd3 100644 --- a/R-package/src/xgboost_custom.cc +++ b/R-package/src/xgboost_custom.cc @@ -53,7 +53,7 @@ bool CheckNAN(double v) { double LogGamma(double v) { return lgammafn(v); } -#endif +#endif // !defined(XGBOOST_USE_CUDA) // customize random engine. void CustomGlobalRandomEngine::seed(CustomGlobalRandomEngine::result_type val) { // ignore the seed diff --git a/cmake/build_config.h.in b/cmake/build_config.h.in index b49dde12e123..76195aeca40b 100644 --- a/cmake/build_config.h.in +++ b/cmake/build_config.h.in @@ -1,3 +1,7 @@ +/*! + * Copyright 2019 by Contributors + * \file build_config.h + */ #ifndef XGBOOST_BUILD_CONFIG_H_ #define XGBOOST_BUILD_CONFIG_H_ diff --git a/include/xgboost/base.h b/include/xgboost/base.h index 55c2e4ac7144..7a92bc78d0e4 100644 --- a/include/xgboost/base.h +++ b/include/xgboost/base.h @@ -16,7 +16,7 @@ */ #ifndef XGBOOST_STRICT_R_MODE #define XGBOOST_STRICT_R_MODE 0 -#endif +#endif // XGBOOST_STRICT_R_MODE /*! * \brief Whether always log console message with time. @@ -26,21 +26,21 @@ */ #ifndef XGBOOST_LOG_WITH_TIME #define XGBOOST_LOG_WITH_TIME 1 -#endif +#endif // XGBOOST_LOG_WITH_TIME /*! * \brief Whether customize the logger outputs. */ #ifndef XGBOOST_CUSTOMIZE_LOGGER #define XGBOOST_CUSTOMIZE_LOGGER XGBOOST_STRICT_R_MODE -#endif +#endif // XGBOOST_CUSTOMIZE_LOGGER /*! * \brief Whether to customize global PRNG. */ #ifndef XGBOOST_CUSTOMIZE_GLOBAL_PRNG #define XGBOOST_CUSTOMIZE_GLOBAL_PRNG XGBOOST_STRICT_R_MODE -#endif +#endif // XGBOOST_CUSTOMIZE_GLOBAL_PRNG /*! * \brief Check if alignas(*) keyword is supported. (g++ 4.8 or higher) @@ -49,7 +49,7 @@ #define XGBOOST_ALIGNAS(X) alignas(X) #else #define XGBOOST_ALIGNAS(X) -#endif +#endif // defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4) #if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4) && \ !defined(__CUDACC__) @@ -64,7 +64,7 @@ #else #define XGBOOST_PARALLEL_SORT(X, Y, Z) std::sort((X), (Y), (Z)) #define XGBOOST_PARALLEL_STABLE_SORT(X, Y, Z) std::stable_sort((X), (Y), (Z)) -#endif +#endif // GLIBC VERSION /*! * \brief Tag function as usable by device @@ -73,7 +73,7 @@ #define XGBOOST_DEVICE __host__ __device__ #else #define XGBOOST_DEVICE -#endif +#endif // defined (__CUDA__) || defined(__NVCC__) /*! \brief namespace of xgboost*/ namespace xgboost { @@ -215,8 +215,8 @@ using bst_omp_uint = dmlc::omp_uint; // NOLINT #if __GNUC__ == 4 && __GNUC_MINOR__ < 8 #define override #define final -#endif -#endif +#endif // __GNUC__ == 4 && __GNUC_MINOR__ < 8 +#endif // DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__) } // namespace xgboost /* Always keep this #include at the bottom of xgboost/base.h */ diff --git a/include/xgboost/build_config.h b/include/xgboost/build_config.h index b3a8bcdc3c94..14bb0785b611 100644 --- a/include/xgboost/build_config.h +++ b/include/xgboost/build_config.h @@ -13,6 +13,6 @@ #elif defined(__GNUC__) // Enable __builtin_prefetch for GCC #define XGBOOST_BUILTIN_PREFETCH_PRESENT -#endif +#endif // GUARDS #endif // XGBOOST_BUILD_CONFIG_H_ diff --git a/include/xgboost/c_api.h b/include/xgboost/c_api.h index a64e50b360ee..787397ad9454 100644 --- a/include/xgboost/c_api.h +++ b/include/xgboost/c_api.h @@ -10,11 +10,12 @@ #ifdef __cplusplus #define XGB_EXTERN_C extern "C" #include +#include #else #define XGB_EXTERN_C #include #include -#endif +#endif // __cplusplus // XGBoost C API will include APIs in Rabit C API #include @@ -23,7 +24,7 @@ #define XGB_DLL XGB_EXTERN_C __declspec(dllexport) #else #define XGB_DLL XGB_EXTERN_C -#endif +#endif // defined(_MSC_VER) || defined(_WIN32) // manually define unsigned long typedef uint64_t bst_ulong; // NOLINT(*) @@ -49,7 +50,7 @@ typedef struct { // NOLINT(*) long* offset; // NOLINT(*) #else int64_t* offset; // NOLINT(*) -#endif +#endif // __APPLE__ /*! \brief labels of each instance */ float* label; /*! \brief weight of each instance, can be NULL */ @@ -562,7 +563,7 @@ XGB_DLL int XGBoosterGetAttr(BoosterHandle handle, * * \param handle handle * \param key The key of the attribute. - * \param value The value to be saved. + * \param value The value to be saved. * If nullptr, the attribute would be deleted. * \return 0 when success, -1 when failure happens */ diff --git a/include/xgboost/learner.h b/include/xgboost/learner.h index b31d90d2aa96..187d27a2d6ab 100644 --- a/include/xgboost/learner.h +++ b/include/xgboost/learner.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "./base.h" diff --git a/include/xgboost/logging.h b/include/xgboost/logging.h index ac6adf36a5cd..4241d095d8fd 100644 --- a/include/xgboost/logging.h +++ b/include/xgboost/logging.h @@ -25,7 +25,7 @@ class BaseLogger { BaseLogger() { #if XGBOOST_LOG_WITH_TIME log_stream_ << "[" << dmlc::DateLogger().HumanDate() << "] "; -#endif +#endif // XGBOOST_LOG_WITH_TIME } std::ostream& stream() { return log_stream_; } // NOLINT @@ -116,14 +116,14 @@ class LogCallbackRegistry { return nullptr; } }; -#endif +#endif // !defined(XGBOOST_STRICT_R_MODE) || XGBOOST_STRICT_R_MODE == 0 using LogCallbackRegistryStore = dmlc::ThreadLocalStore; // Redefines LOG_WARNING for controling verbosity #if defined(LOG_WARNING) #undef LOG_WARNING -#endif +#endif // defined(LOG_WARNING) #define LOG_WARNING \ if (::xgboost::ConsoleLogger::ShouldLog( \ ::xgboost::ConsoleLogger::LV::kWarning)) \ @@ -133,7 +133,7 @@ using LogCallbackRegistryStore = dmlc::ThreadLocalStore; // Redefines LOG_INFO for controling verbosity #if defined(LOG_INFO) #undef LOG_INFO -#endif +#endif // defined(LOG_INFO) #define LOG_INFO \ if (::xgboost::ConsoleLogger::ShouldLog( \ ::xgboost::ConsoleLogger::LV::kInfo)) \ @@ -142,7 +142,7 @@ using LogCallbackRegistryStore = dmlc::ThreadLocalStore; #if defined(LOG_DEBUG) #undef LOG_DEBUG -#endif +#endif // defined(LOG_DEBUG) #define LOG_DEBUG \ if (::xgboost::ConsoleLogger::ShouldLog( \ ::xgboost::ConsoleLogger::LV::kDebug)) \ @@ -152,7 +152,7 @@ using LogCallbackRegistryStore = dmlc::ThreadLocalStore; // redefines the logging macro if not existed #ifndef LOG #define LOG(severity) LOG_##severity.stream() -#endif +#endif // LOG // Enable LOG(CONSOLE) for print messages to console. #define LOG_CONSOLE ::xgboost::ConsoleLogger( \ diff --git a/include/xgboost/predictor.h b/include/xgboost/predictor.h index 25503185f88c..95af0f03d09d 100644 --- a/include/xgboost/predictor.h +++ b/include/xgboost/predictor.h @@ -7,11 +7,14 @@ #pragma once #include #include + #include #include #include +#include #include #include + #include "../../src/gbm/gbtree_model.h" #include "../../src/common/host_device_vector.h" diff --git a/src/common/common.cc b/src/common/common.cc index e1602004b5c2..f6b6a2272a15 100644 --- a/src/common/common.cc +++ b/src/common/common.cc @@ -27,6 +27,6 @@ GlobalRandomEngine& GlobalRandom() { int AllVisibleImpl::AllVisible() { return 0; } -#endif +#endif // !defined(XGBOOST_USE_CUDA) } // namespace xgboost diff --git a/src/common/common.h b/src/common/common.h index 53b8a8c6a932..d0fb5ca9ff05 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -26,7 +26,7 @@ #define WITH_CUDA() false -#endif +#endif // defined(__CUDACC__) namespace dh { #if defined(__CUDACC__) @@ -44,7 +44,7 @@ inline cudaError_t ThrowOnCudaError(cudaError_t code, const char *file, } return code; } -#endif +#endif // defined(__CUDACC__) } // namespace dh namespace xgboost { diff --git a/src/common/compressed_iterator.h b/src/common/compressed_iterator.h index 2d834aae6802..0f6e93695436 100644 --- a/src/common/compressed_iterator.h +++ b/src/common/compressed_iterator.h @@ -10,7 +10,7 @@ #ifdef __CUDACC__ #include "device_helpers.cuh" -#endif +#endif // __CUDACC__ namespace xgboost { namespace common { @@ -115,7 +115,7 @@ class CompressedBufferWriter { symbol >>= 8; } } -#endif +#endif // __CUDACC__ template void Write(CompressedByteT *buffer, IterT input_begin, IterT input_end) { diff --git a/src/common/hist_util.cc b/src/common/hist_util.cc index 1646bd031698..ad2e1696ed5e 100644 --- a/src/common/hist_util.cc +++ b/src/common/hist_util.cc @@ -19,7 +19,7 @@ #define PREFETCH_READ_T0(addr) __builtin_prefetch(reinterpret_cast(addr), 0, 3) #else // no SW pre-fetching available; PREFETCH_READ_T0 is no-op #define PREFETCH_READ_T0(addr) do {} while (0) -#endif +#endif // defined(XGBOOST_MM_PREFETCH_PRESENT) namespace xgboost { namespace common { @@ -544,7 +544,7 @@ void GHistBuilder::BuildBlockHist(const std::vector& gpair, #if defined(_OPENMP) const auto nthread = static_cast(this->nthread_); -#endif +#endif // defined(_OPENMP) tree::GradStats* p_hist = hist.data(); #pragma omp parallel for num_threads(nthread) schedule(guided) @@ -590,7 +590,7 @@ void GHistBuilder::SubtractionTrick(GHistRow self, GHistRow sibling, GHistRow pa #if defined(_OPENMP) const auto nthread = static_cast(this->nthread_); -#endif +#endif // defined(_OPENMP) tree::GradStats* p_self = self.data(); tree::GradStats* p_sibling = sibling.data(); tree::GradStats* p_parent = parent.data(); diff --git a/src/common/host_device_vector.cc b/src/common/host_device_vector.cc index ac7f3860e16b..98e760a5067a 100644 --- a/src/common/host_device_vector.cc +++ b/src/common/host_device_vector.cc @@ -159,4 +159,4 @@ template class HostDeviceVector; } // namespace xgboost -#endif +#endif // XGBOOST_USE_CUDA diff --git a/src/common/host_device_vector.h b/src/common/host_device_vector.h index c2ae0110a512..b1ae87e638be 100644 --- a/src/common/host_device_vector.h +++ b/src/common/host_device_vector.h @@ -57,6 +57,7 @@ #include #include #include +#include #include #include "common.h" @@ -66,7 +67,7 @@ // is included from a .cu file #ifdef __CUDACC__ #include -#endif +#endif // __CUDACC__ namespace xgboost { @@ -74,7 +75,7 @@ namespace xgboost { // Sets a function to call instead of cudaSetDevice(); // only added for testing void SetCudaSetDeviceHandler(void (*handler)(int)); -#endif +#endif // __CUDACC__ template struct HostDeviceVectorImpl; @@ -233,7 +234,7 @@ class HostDeviceVector { void ScatterFrom(thrust::device_ptr begin, thrust::device_ptr end); void GatherTo(thrust::device_ptr begin, thrust::device_ptr end) const; -#endif +#endif // __CUDACC__ void Fill(T v); void Copy(const HostDeviceVector& other); diff --git a/src/common/math.h b/src/common/math.h index f2fb6e653693..20879aabaa45 100644 --- a/src/common/math.h +++ b/src/common/math.h @@ -123,7 +123,7 @@ inline bool CheckNAN(T v) { return (_isnan(v) != 0); #else return std::isnan(v); -#endif +#endif // _MSC_VER } #endif // XGBOOST_STRICT_R_MODE_ @@ -149,7 +149,7 @@ XGBOOST_DEVICE inline T LogGamma(T v) { #else return lgamma(v); -#endif +#endif // _MSC_VER } #endif // XGBOOST_STRICT_R_MODE && !defined(XGBOOST_USE_CUDA) diff --git a/src/common/random.h b/src/common/random.h index ecce04765478..66b73fdbcd37 100644 --- a/src/common/random.h +++ b/src/common/random.h @@ -66,7 +66,7 @@ typedef CustomGlobalRandomEngine GlobalRandomEngine; * \brief global random engine */ using GlobalRandomEngine = RandomEngine; -#endif +#endif // XGBOOST_CUSTOMIZE_GLOBAL_PRNG /*! * \brief global singleton of a random engine. diff --git a/src/common/span.h b/src/common/span.h index 9fa058830e3f..bcaf1b178cb0 100644 --- a/src/common/span.h +++ b/src/common/span.h @@ -62,7 +62,7 @@ #define __span_noexcept noexcept -#endif +#endif // defined(_MSC_VER) && _MSC_VER < 1910 namespace xgboost { namespace common { @@ -85,7 +85,7 @@ namespace common { #define SPAN_CHECK KERNEL_CHECK #else #define SPAN_CHECK CHECK // check from dmlc -#endif +#endif // __CUDA_ARCH__ namespace detail { /*! @@ -101,7 +101,7 @@ using ptrdiff_t = int64_t; // NOLINT constexpr const detail::ptrdiff_t dynamic_extent = -1; // NOLINT #else constexpr detail::ptrdiff_t dynamic_extent = -1; // NOLINT -#endif +#endif // defined(_MSC_VER) && _MSC_VER < 1910 enum class byte : unsigned char {}; // NOLINT diff --git a/src/common/timer.h b/src/common/timer.h index 2d9a5ac62849..970eeb8082d0 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -81,7 +81,7 @@ struct Monitor { cudaSetDevice(device); cudaDeviceSynchronize(); } -#endif +#endif // __CUDACC__ } statistics_map[name].timer.Start(); } @@ -96,7 +96,7 @@ struct Monitor { cudaSetDevice(device); cudaDeviceSynchronize(); } -#endif +#endif // __CUDACC__ } this->Stop(name); } diff --git a/src/common/transform.h b/src/common/transform.h index 37a9236f891e..c5382b4d7abe 100644 --- a/src/common/transform.h +++ b/src/common/transform.h @@ -6,6 +6,7 @@ #include #include +#include #include #include // enable_if @@ -15,7 +16,7 @@ #if defined (__CUDACC__) #include "device_helpers.cuh" -#endif +#endif // defined (__CUDACC__) namespace xgboost { namespace common { @@ -32,7 +33,7 @@ __global__ void LaunchCUDAKernel(Functor _func, Range _range, _func(i, _spans...); } } -#endif +#endif // defined(__CUDACC__) } // namespace detail @@ -155,7 +156,7 @@ class Transform { void LaunchCUDA(Functor _func, HDV*... _vectors) const { LOG(FATAL) << "Not part of device code. WITH_CUDA: " << WITH_CUDA(); } -#endif +#endif // defined(__CUDACC__) template void LaunchCPU(Functor func, HDV*... vectors) const { diff --git a/src/data/data.cc b/src/data/data.cc index ded6b3a9c4c1..24791d7a1503 100644 --- a/src/data/data.cc +++ b/src/data/data.cc @@ -15,7 +15,7 @@ #if DMLC_ENABLE_STD_THREAD #include "./sparse_page_source.h" #include "./sparse_page_dmatrix.h" -#endif +#endif // DMLC_ENABLE_STD_THREAD namespace dmlc { DMLC_REGISTRY_ENABLE(::xgboost::data::SparsePageFormatReg); @@ -264,7 +264,7 @@ DMatrix* DMatrix::Create(dmlc::Parser* parser, #else LOG(FATAL) << "External memory is not enabled in mingw"; return nullptr; -#endif +#endif // DMLC_ENABLE_STD_THREAD } } @@ -285,7 +285,7 @@ DMatrix* DMatrix::Create(std::unique_ptr&& source, #else LOG(FATAL) << "External memory is not enabled in mingw"; return nullptr; -#endif +#endif // DMLC_ENABLE_STD_THREAD } } } // namespace xgboost diff --git a/src/data/simple_dmatrix.h b/src/data/simple_dmatrix.h index 308baed6a3aa..34b6b2c190d5 100644 --- a/src/data/simple_dmatrix.h +++ b/src/data/simple_dmatrix.h @@ -9,9 +9,13 @@ #include #include + #include #include +#include +#include #include + #include "simple_csr_source.h" namespace xgboost { diff --git a/src/data/sparse_page_dmatrix.cc b/src/data/sparse_page_dmatrix.cc index 3a97b08f4445..cb4ad54063cd 100644 --- a/src/data/sparse_page_dmatrix.cc +++ b/src/data/sparse_page_dmatrix.cc @@ -100,4 +100,4 @@ bool SparsePageDMatrix::SingleColBlock() const { } } // namespace data } // namespace xgboost -#endif +#endif // DMLC_ENABLE_STD_THREAD diff --git a/src/data/sparse_page_dmatrix.h b/src/data/sparse_page_dmatrix.h index 706b15fc36aa..8b4352b09d5c 100644 --- a/src/data/sparse_page_dmatrix.h +++ b/src/data/sparse_page_dmatrix.h @@ -9,9 +9,11 @@ #include #include +#include #include #include #include + #include "sparse_page_source.h" namespace xgboost { diff --git a/src/data/sparse_page_source.cc b/src/data/sparse_page_source.cc index b7164e51a201..e8f701d421cc 100644 --- a/src/data/sparse_page_source.cc +++ b/src/data/sparse_page_source.cc @@ -29,7 +29,7 @@ GetCacheShards(const std::string& cache_info) { cache_shards[0] = cache_info.substr(0, 2) + cache_shards[0]; return cache_shards; } -#endif +#endif // (defined _WIN32) || (defined __CYGWIN__) return xgboost::common::Split(cache_info, ':'); } @@ -291,4 +291,4 @@ void SparsePageSource::CreateColumnPage(DMatrix* src, } } // namespace data } // namespace xgboost -#endif +#endif // DMLC_ENABLE_STD_THREAD diff --git a/src/data/sparse_page_source.h b/src/data/sparse_page_source.h index 0e02b52dad35..0be2bd3fcbd3 100644 --- a/src/data/sparse_page_source.h +++ b/src/data/sparse_page_source.h @@ -10,9 +10,12 @@ #include #include #include -#include + #include +#include #include +#include + #include "sparse_page_writer.h" namespace xgboost { diff --git a/src/data/sparse_page_writer.h b/src/data/sparse_page_writer.h index 407f4ac19f5a..835663e21371 100644 --- a/src/data/sparse_page_writer.h +++ b/src/data/sparse_page_writer.h @@ -19,7 +19,7 @@ #if DMLC_ENABLE_STD_THREAD #include #include -#endif +#endif // DMLC_ENABLE_STD_THREAD namespace xgboost { namespace data { diff --git a/src/gbm/gbtree_model.h b/src/gbm/gbtree_model.h index f89a0afed765..0ef46fbffb30 100644 --- a/src/gbm/gbtree_model.h +++ b/src/gbm/gbtree_model.h @@ -5,6 +5,8 @@ #include #include #include + +#include #include #include #include diff --git a/src/learner.cc b/src/learner.cc index 4d0435608c8f..1269a6b2b6d7 100644 --- a/src/learner.cc +++ b/src/learner.cc @@ -178,7 +178,7 @@ class LearnerImpl : public Learner { static void AssertGPUSupport() { #ifndef XGBOOST_USE_CUDA LOG(FATAL) << "XGBoost version not compiled with GPU support."; -#endif +#endif // XGBOOST_USE_CUDA } @@ -387,7 +387,7 @@ class LearnerImpl : public Learner { cfg_["predictor"] = "cpu_predictor"; kv.second = "cpu_predictor"; } -#endif +#endif // XGBOOST_USE_CUDA } } attributes_ = diff --git a/src/linear/linear_updater.cc b/src/linear/linear_updater.cc index fa7771edafad..3ec9e005b024 100644 --- a/src/linear/linear_updater.cc +++ b/src/linear/linear_updater.cc @@ -30,6 +30,6 @@ DMLC_REGISTRY_LINK_TAG(updater_shotgun); DMLC_REGISTRY_LINK_TAG(updater_coordinate); #ifdef XGBOOST_USE_CUDA DMLC_REGISTRY_LINK_TAG(updater_gpu_coordinate); -#endif +#endif // XGBOOST_USE_CUDA } // namespace linear } // namespace xgboost diff --git a/src/logging.cc b/src/logging.cc index b292f8f81c1e..2dc6eeb4332a 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -35,7 +35,7 @@ TrackerLogger::~TrackerLogger() { } // namespace xgboost -#endif +#endif // !defined(XGBOOST_STRICT_R_MODE) || XGBOOST_STRICT_R_MODE == 0 namespace xgboost { diff --git a/src/metric/elementwise_metric.cc b/src/metric/elementwise_metric.cc index 9773f525c423..0a3e673c11f8 100644 --- a/src/metric/elementwise_metric.cc +++ b/src/metric/elementwise_metric.cc @@ -5,4 +5,4 @@ #if !defined(XGBOOST_USE_CUDA) #include "elementwise_metric.cu" -#endif +#endif // !defined(XGBOOST_USE_CUDA) diff --git a/src/metric/elementwise_metric.cu b/src/metric/elementwise_metric.cu index 0675f1a238fe..cb7f9153dbbe 100644 --- a/src/metric/elementwise_metric.cu +++ b/src/metric/elementwise_metric.cu @@ -144,7 +144,7 @@ class MetricsReduction { result.weights_sum_ += res_per_device[i].weights_sum_; } } -#endif +#endif // defined(XGBOOST_USE_CUDA) return result; } @@ -152,7 +152,7 @@ class MetricsReduction { EvalRow policy_; #if defined(XGBOOST_USE_CUDA) std::vector allocators_; -#endif +#endif // defined(XGBOOST_USE_CUDA) }; struct EvalRowRMSE { diff --git a/src/objective/hinge.cc b/src/objective/hinge.cc index f7cdeeb86bed..4476ff62840c 100644 --- a/src/objective/hinge.cc +++ b/src/objective/hinge.cc @@ -15,4 +15,4 @@ DMLC_REGISTRY_FILE_TAG(hinge_obj); #ifndef XGBOOST_USE_CUDA #include "hinge.cu" -#endif +#endif // XGBOOST_USE_CUDA diff --git a/src/objective/hinge.cu b/src/objective/hinge.cu index 46110813d5c6..ea4ad0cf63a8 100644 --- a/src/objective/hinge.cu +++ b/src/objective/hinge.cu @@ -16,7 +16,7 @@ namespace obj { #if defined(XGBOOST_USE_CUDA) DMLC_REGISTRY_FILE_TAG(hinge_obj_gpu); -#endif +#endif // defined(XGBOOST_USE_CUDA) struct HingeObjParam : public dmlc::Parameter { int n_gpus; diff --git a/src/objective/multiclass_obj.cc b/src/objective/multiclass_obj.cc index 2041bd56e560..ec6616034b27 100644 --- a/src/objective/multiclass_obj.cc +++ b/src/objective/multiclass_obj.cc @@ -15,4 +15,4 @@ DMLC_REGISTRY_FILE_TAG(multiclass_obj); #ifndef XGBOOST_USE_CUDA #include "multiclass_obj.cu" -#endif +#endif // XGBOOST_USE_CUDA diff --git a/src/objective/multiclass_obj.cu b/src/objective/multiclass_obj.cu index 085bc8bf10b9..dcea023702b7 100644 --- a/src/objective/multiclass_obj.cu +++ b/src/objective/multiclass_obj.cu @@ -21,7 +21,7 @@ namespace obj { #if defined(XGBOOST_USE_CUDA) DMLC_REGISTRY_FILE_TAG(multiclass_obj_gpu); -#endif +#endif // defined(XGBOOST_USE_CUDA) struct SoftmaxMultiClassParam : public dmlc::Parameter { int num_class; diff --git a/src/objective/objective.cc b/src/objective/objective.cc index 9f6f190fa9e2..c359431b4011 100644 --- a/src/objective/objective.cc +++ b/src/objective/objective.cc @@ -38,7 +38,7 @@ DMLC_REGISTRY_LINK_TAG(multiclass_obj_gpu); DMLC_REGISTRY_LINK_TAG(regression_obj); DMLC_REGISTRY_LINK_TAG(hinge_obj); DMLC_REGISTRY_LINK_TAG(multiclass_obj); -#endif +#endif // XGBOOST_USE_CUDA DMLC_REGISTRY_LINK_TAG(rank_obj); } // namespace obj } // namespace xgboost diff --git a/src/objective/regression_obj.cc b/src/objective/regression_obj.cc index e74bbf688535..663989fbd5c3 100644 --- a/src/objective/regression_obj.cc +++ b/src/objective/regression_obj.cc @@ -15,4 +15,4 @@ DMLC_REGISTRY_FILE_TAG(regression_obj); #ifndef XGBOOST_USE_CUDA #include "regression_obj.cu" -#endif +#endif // XGBOOST_USE_CUDA diff --git a/src/objective/regression_obj.cu b/src/objective/regression_obj.cu index 26bc314e3edf..e7bdd9947b21 100644 --- a/src/objective/regression_obj.cu +++ b/src/objective/regression_obj.cu @@ -24,7 +24,7 @@ namespace obj { #if defined(XGBOOST_USE_CUDA) DMLC_REGISTRY_FILE_TAG(regression_obj_gpu); -#endif +#endif // defined(XGBOOST_USE_CUDA) struct RegLossParam : public dmlc::Parameter { float scale_pos_weight; diff --git a/src/predictor/predictor.cc b/src/predictor/predictor.cc index e88528287e4e..63922ff216e2 100644 --- a/src/predictor/predictor.cc +++ b/src/predictor/predictor.cc @@ -29,7 +29,7 @@ namespace predictor { // List of files that will be force linked in static links. #ifdef XGBOOST_USE_CUDA DMLC_REGISTRY_LINK_TAG(gpu_predictor); -#endif +#endif // XGBOOST_USE_CUDA DMLC_REGISTRY_LINK_TAG(cpu_predictor); } // namespace predictor } // namespace xgboost diff --git a/src/tree/split_evaluator.cc b/src/tree/split_evaluator.cc index 52a022e64770..9254757e39e9 100644 --- a/src/tree/split_evaluator.cc +++ b/src/tree/split_evaluator.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tree/split_evaluator.h b/src/tree/split_evaluator.h index 968d6fe770c1..142b71097a13 100644 --- a/src/tree/split_evaluator.h +++ b/src/tree/split_evaluator.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tree/tree_updater.cc b/src/tree/tree_updater.cc index a1d4432aa91d..c5eb0dd2ce30 100644 --- a/src/tree/tree_updater.cc +++ b/src/tree/tree_updater.cc @@ -37,6 +37,6 @@ DMLC_REGISTRY_LINK_TAG(updater_sync); #ifdef XGBOOST_USE_CUDA DMLC_REGISTRY_LINK_TAG(updater_gpu); DMLC_REGISTRY_LINK_TAG(updater_gpu_hist); -#endif +#endif // XGBOOST_USE_CUDA } // namespace tree } // namespace xgboost diff --git a/src/tree/updater_colmaker.cc b/src/tree/updater_colmaker.cc index 0e1e436205d3..97fdfa0451b1 100644 --- a/src/tree/updater_colmaker.cc +++ b/src/tree/updater_colmaker.cc @@ -597,7 +597,7 @@ class ColMaker: public TreeUpdater { const auto num_features = static_cast(feat_set.size()); #if defined(_OPENMP) const int batch_size = std::max(static_cast(num_features / this->nthread_ / 32), 1); - #endif + #endif // defined(_OPENMP) int poption = param_.parallel_option; if (poption == 2) { poption = static_cast(num_features) * 2 < this->nthread_ ? 1 : 0; diff --git a/src/tree/updater_quantile_hist.h b/src/tree/updater_quantile_hist.h index ba31dc55a33c..288fbc867926 100644 --- a/src/tree/updater_quantile_hist.h +++ b/src/tree/updater_quantile_hist.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "./param.h"