forked from dmlc/xgboost
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6202d0
commit 117fb97
Showing
5 changed files
with
44 additions
and
24 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
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,20 @@ | ||
/** | ||
* Copyright 2023, XGBoost Contributors | ||
*/ | ||
#include "sparse_page_source.h" | ||
|
||
#include <unistd.h> // for getpagesize | ||
|
||
namespace xgboost::data { | ||
std::size_t PadPageForMMAP(std::size_t file_bytes, dmlc::Stream* fo) { | ||
decltype(file_bytes) page_size = getpagesize(); | ||
CHECK(page_size != 0 && page_size % 2 == 0) << "Failed to get page size on the current system."; | ||
CHECK_NE(file_bytes, 0) << "Empty page encountered."; | ||
auto n = file_bytes / page_size; | ||
auto padded = (n + !!(file_bytes % page_size != 0)) * page_size; | ||
auto padding = padded - file_bytes; | ||
std::vector<std::uint8_t> padding_bytes(padding, 0); | ||
fo->Write(padding_bytes.data(), padding_bytes.size()); | ||
return padded; | ||
} | ||
} // namespace xgboost::data |
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