You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: make solver settings constructible without CUDA
Two things forced CUDA on anything that merely constructed or inspected solver
settings, even when it never touched a device.
1. pdlp_solver_settings_t held pdlp_warm_start_data_t by value. That type owns
nine rmm::device_uvector, and its default constructor is out-of-line in a CUDA
translation unit because device_uvector has no default ctor -- it needs a
stream, and building even a zero-size one calls cudaGetDevice. So constructing
settings pulled in libcuopt.
It is now held by shared_ptr, allocated lazily via ensure_pdlp_warm_start_data().
shared_ptr rather than unique_ptr specifically: shared_ptr type-erases its
deleter into the control block at construction, so a host-only translation unit
can copy and destroy the member without the complete type. unique_ptr would
only move the problem from the constructor to the destructor.
The ~88 device-side uses inside set_pdlp_warm_start_data() are unchanged; a
local reference alias keeps that code reading as before.
2. populate_from_data_model_view() inlined both the GPU and CPU warm-start paths
in one if/else. The GPU direction is only reachable when handle != nullptr, but
the compiler instantiated both branches into every translation unit including
the header -- dragging convert_to_gpu_warmstart, convert_to_cpu_warmstart and
pdlp_warm_start_data_t(view, stream) along with it.
Split into apply_warmstart_gpu_target() (declared in the header, defined in
optimization_problem.cu) and apply_warmstart_cpu_target() (host-only, inline),
selected by a kHostOnly template parameter dispatched with `if constexpr`.
The compile-time dispatch is the point: a host-only caller never *instantiates*
the GPU branch, so it emits no reference to it. A runtime `if` would not help.
Also moves the warm-start accessors that need no allocation into
solver_settings_accessors.cpp, leaving the CUDA TU with only members that do.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
0 commit comments