Skip to content

Introducing MemoryType::PINNED_HOST#731

Merged
rapids-bot[bot] merged 5 commits intorapidsai:mainfrom
madsbk:pinned_host_memory_type
Dec 11, 2025
Merged

Introducing MemoryType::PINNED_HOST#731
rapids-bot[bot] merged 5 commits intorapidsai:mainfrom
madsbk:pinned_host_memory_type

Conversation

@madsbk
Copy link
Member

@madsbk madsbk commented Dec 10, 2025

No description provided.

@madsbk madsbk self-assigned this Dec 10, 2025
@madsbk madsbk added breaking Introduces a breaking change improvement Improves an existing functionality labels Dec 10, 2025
@madsbk madsbk force-pushed the pinned_host_memory_type branch from 28eafb0 to f5a0173 Compare December 10, 2025 15:10
@madsbk madsbk force-pushed the pinned_host_memory_type branch from f5a0173 to dd74085 Compare December 10, 2025 15:11
@madsbk madsbk marked this pull request as ready for review December 10, 2025 15:43
@madsbk madsbk requested review from a team as code owners December 10, 2025 15:43
@rapidsai rapidsai deleted a comment from copy-pr-bot bot Dec 10, 2025
Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left only minor non-blocking questions, otherwise LGTM.

return TableChunk(std::move(table), stream());
}
case MemoryType::HOST:
case MemoryType::PINNED_HOST:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we implement an abstraction, or an type checker perhaps to use in such situations? E.g.:

is_host_memory(MemoryType type) {
    switch (mem_type) {
    case MemoryType::HOST:
    case MemoryType::PINNED_HOST:
        return true;
    default:
        return false;
}

Copy link
Member Author

@madsbk madsbk Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait. In this case, I think we want to change behavior for PINNED_HOST: #726 (comment)

Comment on lines 15 to 16
HOST = 1, ///< Host memory
PINNED_HOST = 2 ///< Pinned host memory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be other way around? HOST = 2 and PINNED_HOST=1. Then they will match the indices of MEMORY_TYPES and MEMORY_TYPE_NAMES. Which could be important when someone static_casts the enum to size_t.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, consider the following

auto m = MemoryType::PINNED_HOST;
auto m_to_s = MEMORY_TYPE_NAMES[static_cast<size_t>(m)];  // == "HOST" 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition clearly bases itself off of MEMORY_TYPES and not MemoryType:

/// @brief Memory type names sorted to match `MEMORY_TYPES`.
constexpr std::array<char const*, MEMORY_TYPES.size()> MEMORY_TYPE_NAMES{

But I agree this is confusing, and I was going to say that one alternative could be to provide a function to get names, then I realized it already exists and in fact will hit the exact case you're pointing out.

Thus I agree, we either need to match the order or find a way to make this more robust providing an explicit separation of enums and the MEMORY_TYPES array providing the actual ordering.

Copy link
Member Author

@madsbk madsbk Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It was indeed my intention to have MEMORY_TYPES define the order of preference.
For now, let’s also sort MemoryType: 7410e76.

In a follow-up we should introduce a proper class for arrays that can be indexed with MemoryType without using static_cast<std::size_t>, and that enforces the correct ordering.

@madsbk madsbk requested a review from nirandaperera December 11, 2025 08:43
Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mads and Niranda.

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny suggestions

@madsbk madsbk force-pushed the pinned_host_memory_type branch from 7660997 to 7410e76 Compare December 11, 2025 11:36
@madsbk
Copy link
Member Author

madsbk commented Dec 11, 2025

Thanks everyone

@madsbk
Copy link
Member Author

madsbk commented Dec 11, 2025

/merge

@rapids-bot rapids-bot bot merged commit 904133f into rapidsai:main Dec 11, 2025
89 checks passed
@madsbk madsbk deleted the pinned_host_memory_type branch December 11, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change improvement Improves an existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants