Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use configure_file() to configure version only #4974

Merged
merged 3 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/Version.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function (write_version)
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
configure_file(
${xgboost_SOURCE_DIR}/cmake/build_config.h.in
${xgboost_SOURCE_DIR}/include/xgboost/build_config.h @ONLY)
${xgboost_SOURCE_DIR}/cmake/version_config.h.in
${xgboost_SOURCE_DIR}/include/xgboost/version_config.h @ONLY)
configure_file(
${xgboost_SOURCE_DIR}/cmake/Python_version.in
${xgboost_SOURCE_DIR}/python-package/xgboost/VERSION
Expand Down
17 changes: 0 additions & 17 deletions cmake/build_config.h.in

This file was deleted.

11 changes: 11 additions & 0 deletions cmake/version_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* Copyright 2019 XGBoost contributors
*/
#ifndef XGBOOST_VERSION_CONFIG_H_
#define XGBOOST_VERSION_CONFIG_H_

#define XGBOOST_VER_MAJOR @xgboost_VERSION_MAJOR@
#define XGBOOST_VER_MINOR @xgboost_VERSION_MINOR@
#define XGBOOST_VER_PATCH @xgboost_VERSION_PATCH@

#endif // XGBOOST_VERSION_CONFIG_H_
17 changes: 14 additions & 3 deletions include/xgboost/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@
#define XGBOOST_DEVICE
#endif // defined (__CUDA__) || defined(__NVCC__)

// These check are for Makefile.
#if !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined(XGBOOST_BUILTIN_PREFETCH_PRESENT)
/* default logic for software pre-fetching */
#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))) || defined(__INTEL_COMPILER)
// Enable _mm_prefetch for Intel compiler and MSVC+x86
#define XGBOOST_MM_PREFETCH_PRESENT
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
#elif defined(__GNUC__)
// Enable __builtin_prefetch for GCC
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
#endif // GUARDS

#endif // !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined()

/*! \brief namespace of xgboost*/
namespace xgboost {
/*!
Expand Down Expand Up @@ -232,7 +246,4 @@ using XGBoostVersionT = int32_t;
#endif // DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__)
} // namespace xgboost

/* Always keep this #include at the bottom of xgboost/base.h */
#include <xgboost/build_config.h>
hcho3 marked this conversation as resolved.
Show resolved Hide resolved

#endif // XGBOOST_BASE_H_
28 changes: 0 additions & 28 deletions include/xgboost/build_config.h

This file was deleted.

11 changes: 11 additions & 0 deletions include/xgboost/version_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* Copyright 2019 XGBoost contributors
*/
#ifndef XGBOOST_VERSION_CONFIG_H_
#define XGBOOST_VERSION_CONFIG_H_

#define XGBOOST_VER_MAJOR 1
#define XGBOOST_VER_MINOR 0
#define XGBOOST_VER_PATCH 0

#endif // XGBOOST_VERSION_CONFIG_H_
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ target_compile_definitions(objxgboost
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:_MWAITXINTRIN_H_INCLUDED>
${XGBOOST_DEFINITIONS})

if (XGBOOST_MM_PREFETCH_PRESENT)
target_compile_definitions(objxgboost
PRIVATE
-DXGBOOST_MM_PREFETCH_PRESENT=1)
endif(XGBOOST_MM_PREFETCH_PRESENT)
if (XGBOOST_BUILTIN_PREFETCH_PRESENT)
target_compile_definitions(objxgboost
PRIVATE
-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1)
endif (XGBOOST_BUILTIN_PREFETCH_PRESENT)

if (USE_OPENMP)
find_package(OpenMP REQUIRED)
if (OpenMP_CXX_FOUND OR OPENMP_FOUND)
Expand Down
12 changes: 6 additions & 6 deletions src/c_api/c_api.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// Copyright (c) 2014-2019 by Contributors

#include <xgboost/data.h>
#include <xgboost/learner.h>
#include <xgboost/c_api.h>
#include <xgboost/logging.h>

#include <dmlc/thread_local.h>
#include <rabit/rabit.h>
#include <rabit/c_api.h>
Expand All @@ -16,6 +10,12 @@
#include <string>
#include <memory>

#include "xgboost/data.h"
#include "xgboost/learner.h"
#include "xgboost/c_api.h"
#include "xgboost/logging.h"
#include "xgboost/version_config.h"
hcho3 marked this conversation as resolved.
Show resolved Hide resolved

#include "c_api_error.h"
#include "../data/simple_csr_source.h"
#include "../common/math.h"
Expand Down
6 changes: 4 additions & 2 deletions src/common/hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
* Copyright 2017-2019 by Contributors
* \file hist_util.cc
*/
#include "./hist_util.h"
#include <dmlc/timer.h>
#include <rabit/rabit.h>
#include <dmlc/omp.h>

#include <rabit/rabit.h>
#include <numeric>
#include <vector>

#include "xgboost/base.h"
#include "../common/common.h"
#include "./hist_util.h"
hcho3 marked this conversation as resolved.
Show resolved Hide resolved
#include "./random.h"
#include "./column_matrix.h"
#include "./quantile.h"
Expand Down
1 change: 1 addition & 0 deletions src/common/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "xgboost/logging.h"
#include "xgboost/json.h"
#include "xgboost/version_config.h"
#include "version.h"

namespace xgboost {
Expand Down
13 changes: 7 additions & 6 deletions src/data/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
* Copyright 2015-2019 by Contributors
* \file data.cc
*/
#include <xgboost/data.h>
#include <xgboost/logging.h>
#include <xgboost/build_config.h>
#include <dmlc/registry.h>
#include <cstring>

#include "./sparse_page_writer.h"
#include "./simple_dmatrix.h"
#include "./simple_csr_source.h"
#include "xgboost/data.h"
#include "xgboost/logging.h"
#include "xgboost/version_config.h"
#include "sparse_page_writer.h"
#include "simple_dmatrix.h"
#include "simple_csr_source.h"

hcho3 marked this conversation as resolved.
Show resolved Hide resolved
#include "../common/io.h"
#include "../common/version.h"
#include "../common/group_data.h"
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/c_api/test_c_api.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright by Contributors
// Copyright (c) 2019 by Contributors
#include <gtest/gtest.h>
#include <xgboost/version_config.h>
#include <xgboost/c_api.h>
#include <xgboost/data.h>

Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/common/test_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <dmlc/filesystem.h>
#include <dmlc/io.h>

#include <xgboost/version_config.h>
#include <xgboost/json.h>
#include <xgboost/base.h>

Expand Down Expand Up @@ -58,4 +59,4 @@ TEST(Version, Basic) {
str = str.substr(ptr);
ASSERT_EQ(str.size(), 0);
}
} // namespace xgboost
} // namespace xgboost
5 changes: 3 additions & 2 deletions tests/cpp/test_learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include <gtest/gtest.h>
#include <vector>
#include "helpers.h"
#include <dmlc/filesystem.h>

#include "xgboost/learner.h"
#include "dmlc/filesystem.h"
#include <xgboost/learner.h>
#include <xgboost/version_config.h>

namespace xgboost {

Expand Down