xgboost
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
span.h File Reference
#include <xgboost/base.h>
#include <cstddef>
#include <cstdio>
#include <iterator>
#include <limits>
#include <type_traits>
#include <utility>
Include dependency graph for span.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  xgboost::common::detail::SpanIterator< SpanType, IsConst >
 
struct  xgboost::common::detail::ExtentValue< Extent, Offset, Count >
 
struct  xgboost::common::detail::ExtentAsBytesValue< T, Extent >
 
struct  xgboost::common::detail::IsAllowedExtentConversion< From, To >
 
struct  xgboost::common::detail::IsAllowedElementTypeConversion< From, To >
 
struct  xgboost::common::detail::IsSpanOracle< T >
 
struct  xgboost::common::detail::IsSpanOracle< Span< T, Extent > >
 
struct  xgboost::common::detail::IsSpan< T >
 
struct  xgboost::common::detail::Less< T >
 
struct  xgboost::common::detail::Greater< T >
 
class  xgboost::common::Span< T, Extent >
 span class implementation, based on ISO++20 span<T>. The interface should be the same. More...
 
class  xgboost::common::IterSpan< It >
 A simple custom Span type that uses general iterator instead of pointer. More...
 

Namespaces

 xgboost
 Core data structure for multi-target trees.
 
 xgboost::common
 
 xgboost::common::detail
 

Macros

#define __span_noexcept   noexcept
 span class based on ISO++20 span More...
 
#define KERNEL_CHECK(cond)   (XGBOOST_EXPECT((cond), true) ? static_cast<void>(0) : std::terminate())
 
#define SPAN_CHECK(cond)   KERNEL_CHECK(cond)
 
#define SPAN_LT(lhs, rhs)   SPAN_CHECK((lhs) < (rhs))
 

Typedefs

using xgboost::common::detail::ptrdiff_t = typename std::conditional< std::is_same< std::ptrdiff_t, std::int64_t >::value, std::ptrdiff_t, std::int64_t >::type
 

Enumerations

enum class  xgboost::common::byte : unsigned char
 

Functions

template<class InputIt1 , class InputIt2 , class Compare = detail::Less<decltype(std::declval<InputIt1>().operator*())>>
XGBOOST_DEVICE bool xgboost::common::detail::LexicographicalCompare (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
 
template<class T , std::size_t X, class U , std::size_t Y>
XGBOOST_DEVICE bool xgboost::common::operator== (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t X, class U , std::size_t Y>
constexpr XGBOOST_DEVICE bool xgboost::common::operator!= (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t X, class U , std::size_t Y>
constexpr XGBOOST_DEVICE bool xgboost::common::operator< (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t X, class U , std::size_t Y>
constexpr XGBOOST_DEVICE bool xgboost::common::operator<= (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t X, class U , std::size_t Y>
constexpr XGBOOST_DEVICE bool xgboost::common::operator> (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t X, class U , std::size_t Y>
constexpr XGBOOST_DEVICE bool xgboost::common::operator>= (Span< T, X > l, Span< U, Y > r)
 
template<class T , std::size_t E>
XGBOOST_DEVICE auto xgboost::common::as_bytes (Span< T, E > s) __span_noexcept -> Span< const byte, detail::ExtentAsBytesValue< T, E >::value >
 
template<class T , std::size_t E>
XGBOOST_DEVICE auto xgboost::common::as_writable_bytes (Span< T, E > s) __span_noexcept -> Span< byte, detail::ExtentAsBytesValue< T, E >::value >
 

Variables

constexpr std::size_t xgboost::common::dynamic_extent = std::numeric_limits<std::size_t>::max()
 

Macro Definition Documentation

◆ __span_noexcept

#define __span_noexcept   noexcept

span class based on ISO++20 span

Copyright 2018-2023, XGBoost contributors

About NOLINTs in this file:

If we want Span to work with std interface, like range for loop, the naming must be consistent with std, not XGBoost. Also, the interface also conflicts with XGBoost coding style, specifically, the use of ‘explicit’ keyword.

Some of the code is copied from Guidelines Support Library, here is the license:

Copyright (c) 2015 Microsoft Corporation. All rights reserved.

This code is licensed under the MIT License (MIT).

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The version number 1910 is picked up from GSL.

We might want to use MOODYCAMEL_NOEXCEPT from dmlc/concurrentqueue.h. But there are a lot more definitions in that file would cause warnings/troubles in MSVC 2013. Currently we try to keep the closure of Span as minimal as possible.

There are other workarounds for MSVC, like _Unwrapped, _Verify_range ... Some of these are hidden magics of MSVC and I tried to avoid them. Should any of them become needed, please consult the source code of GSL, and possibly some explanations from this thread:

https://github.com/Microsoft/GSL/pull/664

TODO(trivialfis): Group these MSVC workarounds into a manageable place.

◆ KERNEL_CHECK

#define KERNEL_CHECK (   cond)    (XGBOOST_EXPECT((cond), true) ? static_cast<void>(0) : std::terminate())

◆ SPAN_CHECK

#define SPAN_CHECK (   cond)    KERNEL_CHECK(cond)

◆ SPAN_LT

#define SPAN_LT (   lhs,
  rhs 
)    SPAN_CHECK((lhs) < (rhs))