refactor: split host-only members out of CUDA translation units - #1801
Draft
ramakrishnap-nv wants to merge 1 commit into
Draft
refactor: split host-only members out of CUDA translation units#1801ramakrishnap-nv wants to merge 1 commit into
ramakrishnap-nv wants to merge 1 commit into
Conversation
Several classes are mostly host code but live entirely in .cu files, which means anything needing their host-side members has to link the CUDA library. This separates them so the host halves compile as plain C++. math_optimization/solver_settings.cu -> .cpp + _gpu.cu (713 lines, 5 CUDA) mip_heuristics/solver_settings.cu -> .cu + .cpp (58 lines, 3 CUDA) pdlp/solution_conversion.cu -> + solution_conversion_cpu.cpp Each split follows one rule: host code moves to the .cpp, members taking an rmm::cuda_stream_view or returning a device_uvector stay in the .cu, and the moved members are instantiated explicitly per-member rather than via `template class`. The distinction matters -- `template class` in the .cpp would emit device ctors/dtors for members the host file cannot construct. The explicit instantiations are guarded on MIP_INSTANTIATE_* / PDLP_INSTANTIATE_*, so each new file includes mip_heuristics/mip_constants.hpp. Without it the guards evaluate false and the translation unit silently compiles to zero symbols. Also replaces thrust::count with std::count in solve_remote.cpp; it operates on a host vector, so thrust was gratuitous. No behaviour change: every moved definition is byte-identical, and all files still build into libcuopt exactly as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
This was referenced Aug 25, 2026
Collaborator
Author
|
/ok to test |
CI Test Summary8 failed · 1 passed · 4 skipped
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1 of 4 toward a CUDA-free client library. See #1798 for the full picture (that PR is superseded by this series).
What
Several classes are mostly host code but live entirely in
.cufiles, so anything needing their host-side members has to link the CUDA library. This separates them.math_optimization/solver_settings.cu→.cpp+_gpu.cumip_heuristics/solver_settings.cu→.cu+.cpppdlp/solution_conversion.cu→ +solution_conversion_cpu.cppmath_optimization/solver_settings.cuis the clearest case — 713 lines of parameter handling with 5 lines that touch a stream.The rule each split follows
Host code moves to the
.cpp; members taking anrmm::cuda_stream_viewor returning adevice_uvectorstay in the.cu; moved members are instantiated explicitly per-member rather than viatemplate class.That last point is load-bearing:
template classin the host file would emit device ctors/dtors for members it cannot construct.Gotcha worth knowing
The explicit instantiations are guarded on
MIP_INSTANTIATE_*/PDLP_INSTANTIATE_*, so each new file must includemip_heuristics/mip_constants.hpp. Without it the guards evaluate false and the translation unit silently compiles to zero symbols — no error, just a link failure much later. I hit this during development;nm --defined-onlyon the object is how you catch it.Risk
Low. Every moved definition is byte-identical and all files still build into
libcuoptexactly as before — no target changes here. Also swapsthrust::countforstd::countinsolve_remote.cpp, which operates on a host vector.Testing
Full build + 126 test binaries, 0 errors. 111/125 tests pass; the 14 failures are
cudaErrorUnknownfrom a locally wedgednvidia_uvm, identical on unmodifiedmain.🤖 Generated with Claude Code