From 7e1b06417b8f31c34dd02db2f5eb3e01ee89ced1 Mon Sep 17 00:00:00 2001 From: amdsc21 <96135754+amdsc21@users.noreply.github.com> Date: Wed, 8 Mar 2023 21:09:56 +0100 Subject: [PATCH] finish gbtree.cu porting --- include/xgboost/linalg.h | 8 ++++---- include/xgboost/span.h | 9 ++++++++- src/gbm/gbtree.cu | 6 ++++++ src/gbm/gbtree.hip | 3 +++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/xgboost/linalg.h b/include/xgboost/linalg.h index 18314b89f..b1504bf01 100644 --- a/include/xgboost/linalg.h +++ b/include/xgboost/linalg.h @@ -530,17 +530,17 @@ class TensorView { /** * \brief Number of items in the tensor. */ - LINALG_HD [[nodiscard]] std::size_t Size() const { return size_; } + LINALG_HD std::size_t Size() const { return size_; } /** * \brief Whether this is a contiguous array, both C and F contiguous returns true. */ - LINALG_HD [[nodiscard]] bool Contiguous() const { + LINALG_HD bool Contiguous() const { return data_.size() == this->Size() || this->CContiguous() || this->FContiguous(); } /** * \brief Whether it's a c-contiguous array. */ - LINALG_HD [[nodiscard]] bool CContiguous() const { + LINALG_HD bool CContiguous() const { StrideT stride; static_assert(std::is_same::value); // It's contiguous if the stride can be calculated from shape. @@ -550,7 +550,7 @@ class TensorView { /** * \brief Whether it's a f-contiguous array. */ - LINALG_HD [[nodiscard]] bool FContiguous() const { + LINALG_HD bool FContiguous() const { StrideT stride; static_assert(std::is_same::value); // It's contiguous if the stride can be calculated from shape. diff --git a/include/xgboost/span.h b/include/xgboost/span.h index ee11b1d4e..f85faa09b 100644 --- a/include/xgboost/span.h +++ b/include/xgboost/span.h @@ -114,7 +114,7 @@ namespace common { #define HIP_KERNEL_CHECK(cond) \ do { \ if (XGBOOST_EXPECT(!(cond), false)) { \ - __trap(); \ + __builtin_trap(); \ } \ } while (0) @@ -122,10 +122,17 @@ namespace common { #define __ASSERT_STR_HELPER(x) #x +#if 0 /* need to fix __assert_fail, without __host__ */ #define HIP_KERNEL_CHECK(cond) \ (XGBOOST_EXPECT((cond), true) \ ? static_cast(0) \ : __assert_fail(__ASSERT_STR_HELPER((cond)), __FILE__, __LINE__, __PRETTY_FUNCTION__)) +#else +#define HIP_KERNEL_CHECK(cond) \ + (XGBOOST_EXPECT((cond), true) \ + ? static_cast(0) \ + : __builtin_trap()) +#endif #endif // defined(_MSC_VER) diff --git a/src/gbm/gbtree.cu b/src/gbm/gbtree.cu index acff9de52..d493c87c6 100644 --- a/src/gbm/gbtree.cu +++ b/src/gbm/gbtree.cu @@ -1,7 +1,13 @@ /*! * Copyright 2021 by Contributors */ + +#if defined(XGBOOST_USE_CUDA) #include "../common/device_helpers.cuh" +#elif defined(XGBOOST_USE_HIP) +#include "../common/device_helpers.hip.h" +#endif + #include "xgboost/context.h" #include "xgboost/linalg.h" #include "xgboost/span.h" diff --git a/src/gbm/gbtree.hip b/src/gbm/gbtree.hip index e69de29bb..21d362ece 100644 --- a/src/gbm/gbtree.hip +++ b/src/gbm/gbtree.hip @@ -0,0 +1,3 @@ + +#include "gbtree.cu" +