// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once // Restrained refinement's targets on a GPU (CUDA builds only): the RefinementEngine of RefinementXray.h with // everything per evaluation on the device - the atoms' density (ModelDensityGPU's gather), its transform, the // symmetry composed in reciprocal space, the likelihood target, the derivative map by the inverse transform // of the target's derivatives and every atom's gradient read off it, and the geometry restraints. The host // passes positions in and gets one value and one gradient per atom back. #include #include "RefinementXray.h" // The engine for refining `model` against `refl` on `device`, or null where the GPU cannot take this case (an // atom's box wider than the cell, too many symmetry operators) or its memory is over `budget` bytes. // `b_max`: the largest B an atom may reach, which the gather's reserve is sized for. Throws JFJochException on a // CUDA failure. `nthreads`: the host threads that work out the atoms' densities. std::unique_ptr MakeRefinementEngineGPU(int device, const gemmi::UnitCell &cell, const gemmi::SpaceGroup &sg, double d_min, const RefinementReflections &refl, const gemmi::Model &model, double b_max, size_t budget, size_t *device_bytes = nullptr, size_t nthreads = 1);