-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We will transition to non-default and non-blocking CUDA stream.
- Loading branch information
1 parent
43a647a
commit 9ae71a1
Showing
11 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright 2022 by XGBoost Contributors | ||
*/ | ||
#ifndef XGBOOST_COMMON_CUDA_CONTEXT_CUH_ | ||
#define XGBOOST_COMMON_CUDA_CONTEXT_CUH_ | ||
#include <thrust/execution_policy.h> | ||
|
||
#include "device_helpers.cuh" | ||
|
||
namespace xgboost { | ||
struct CUDAContext { | ||
private: | ||
dh::XGBCachingDeviceAllocator<char> caching_alloc_; | ||
dh::XGBDeviceAllocator<char> alloc_; | ||
|
||
public: | ||
/** | ||
* \brief Caching thrust policy. | ||
*/ | ||
auto CTP() const { return thrust::cuda::par(caching_alloc_).on(dh::DefaultStream()); } | ||
/** | ||
* \brief Thrust policy without caching allocator. | ||
*/ | ||
auto TP() const { return thrust::cuda::par(alloc_).on(dh::DefaultStream()); } | ||
auto Stream() const { return dh::DefaultStream(); } | ||
}; | ||
} // namespace xgboost | ||
#endif // XGBOOST_COMMON_CUDA_CONTEXT_CUH_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright 2022 by XGBoost Contributors | ||
*/ | ||
#include "common/cuda_context.cuh" // CUDAContext | ||
#include "xgboost/context.h" | ||
|
||
namespace xgboost { | ||
CUDAContext const* Context::CUDACtx() const { | ||
if (!cuctx_) { | ||
cuctx_.reset(new CUDAContext{}); | ||
} | ||
return cuctx_.get(); | ||
} | ||
} // namespace xgboost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters