[EM] Support mmap backed ellpack. (#10602)

- Support resource view in ellpack.
- Define the CUDA version of MMAP resource.
- Define the CUDA version of malloc resource.
- Refactor cuda runtime API wrappers, and add memory access related wrappers.
- gather windows macros into a single header.
This commit is contained in:
Jiaming Yuan
2024-07-18 08:20:21 +08:00
committed by GitHub
parent e9fbce9791
commit 292bb677e5
59 changed files with 889 additions and 646 deletions

View File

@@ -7,6 +7,8 @@
#define XGBOOST_BASE_H_
#include <dmlc/omp.h> // for omp_uint, omp_ulong
// Put the windefs here to guard as many files as possible.
#include <xgboost/windefs.h>
#include <cstdint> // for int32_t, uint64_t, int16_t
#include <ostream> // for ostream

View File

@@ -4,13 +4,14 @@
* \author Tianqi Chen
*/
#pragma once
#include "xgboost/collective/result.h"
#include "xgboost/collective/socket.h"
#include <xgboost/collective/result.h>
#include <xgboost/collective/socket.h>
#if defined(_WIN32)
#include <xgboost/windefs.h>
// Socket API
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>

View File

@@ -1,12 +1,8 @@
/**
* Copyright (c) 2022-2024, XGBoost Contributors
* Copyright 2022-2024, XGBoost Contributors
*/
#pragma once
#if !defined(NOMINMAX) && defined(_WIN32)
#define NOMINMAX
#endif // !defined(NOMINMAX)
#include <cerrno> // errno, EINTR, EBADF
#include <climits> // HOST_NAME_MAX
#include <cstddef> // std::size_t
@@ -18,18 +14,12 @@
#if defined(__linux__)
#include <sys/ioctl.h> // for TIOCOUTQ, FIONREAD
#endif // defined(__linux__)
#if !defined(xgboost_IS_MINGW)
#if defined(__MINGW32__)
#define xgboost_IS_MINGW 1
#endif // defined(__MINGW32__)
#endif // xgboost_IS_MINGW
#endif // defined(__linux__)
#if defined(_WIN32)
// Guard the include.
#include <xgboost/windefs.h>
// Socket API
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -41,9 +31,9 @@ using in_port_t = std::uint16_t;
#if !defined(xgboost_IS_MINGW)
using ssize_t = int;
#endif // !xgboost_IS_MINGW()
#endif // !xgboost_IS_MINGW()
#else // UNIX
#else // UNIX
#include <arpa/inet.h> // inet_ntop
#include <fcntl.h> // fcntl, F_GETFL, O_NONBLOCK
@@ -839,7 +829,3 @@ Result INetNToP(H const &host, std::string *p_out) {
} // namespace xgboost
#undef xgboost_CHECK_SYS_CALL
#if defined(xgboost_IS_MINGW)
#undef xgboost_IS_MINGW
#endif

33
include/xgboost/windefs.h Normal file
View File

@@ -0,0 +1,33 @@
/**
* Copyright 2024, XGBoost Contributors
*
* @brief Macro for Windows.
*/
#pragma once
#if !defined(xgboost_IS_WIN)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define xgboost_IS_WIN 1
#endif // defined(_MSC_VER) || defined(__MINGW32__)
#endif // !defined(xgboost_IS_WIN)
#if defined(xgboost_IS_WIN)
#if !defined(NOMINMAX)
#define NOMINMAX
#endif // !defined(NOMINMAX)
// A macro used inside `windows.h` to avoid conflicts with `winsock2.h`
#define WIN32_LEAN_AND_MEAN
#if !defined(xgboost_IS_MINGW)
#if defined(__MINGW32__)
#define xgboost_IS_MINGW 1
#endif // defined(__MINGW32__)
#endif // xgboost_IS_MINGW
#endif // defined(xgboost_IS_WIN)