Skip to content

Commit bf6d3c0

Browse files
Make page size portable by querying it at runtime (#677)
So far the parameter page size in KvikIO has been a compile-time constant (4K). On GH200, however, the page size is 64K. This PR makes it portable by querying its value at runtime. Authors: - Tianyu Liu (https://github.com/kingcrimsontianyu) Approvers: - https://github.com/jakirkham - Lawrence Mitchell (https://github.com/wence-) - Mads R. B. Kristensen (https://github.com/madsbk) URL: #677
1 parent 6f14844 commit bf6d3c0

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

cpp/include/kvikio/parallel_operation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ std::future<std::size_t> parallel_io(F op,
156156
decltype(devPtr_offset)>);
157157

158158
// Single-task guard
159-
if (task_size >= size || page_size >= size) {
159+
if (task_size >= size || get_page_size() >= size) {
160160
return detail::submit_task(op, buf, size, file_offset, devPtr_offset, call_idx, nvtx_color);
161161
}
162162

cpp/include/kvikio/utils.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828

2929
namespace kvikio {
3030

31-
// cuFile defines a page size to 4 KiB
32-
inline constexpr std::size_t page_size = 4096;
31+
std::size_t get_page_size();
3332

3433
[[nodiscard]] off_t convert_size2off(std::size_t x);
3534

cpp/src/utils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <unistd.h>
1718
#include <cstring>
1819
#include <iostream>
1920
#include <map>
@@ -28,6 +29,12 @@
2829

2930
namespace kvikio {
3031

32+
std::size_t get_page_size()
33+
{
34+
static auto const page_size = static_cast<std::size_t>(sysconf(_SC_PAGESIZE));
35+
return page_size;
36+
}
37+
3138
off_t convert_size2off(std::size_t x)
3239
{
3340
KVIKIO_EXPECT(x < static_cast<std::size_t>(std::numeric_limits<off_t>::max()),

0 commit comments

Comments
 (0)