Files
leonarski_f a9d5367013
Build Packages / Create release (push) Successful in 26s
Build Packages / Build documentation (push) Successful in 1m43s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m7s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 11m48s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 7m22s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 12m24s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 25m29s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 29m41s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 21m44s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 24m41s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 26m9s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 26m3s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 28m28s
Build Packages / Generate python client (push) Successful in 27s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 31m16s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m44s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 26m27s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 22m52s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 27m44s
Build Packages / Unit tests (push) Successful in 1h46m55s
Build Packages / Validation Battery (push) Successful in 52m50s
v1.0.0-rc.181 (#92)
* Rugnux: Several rotation sweeps of one crystal are merged as one dataset (`rugnux a_master.h5 b_master.h5`), on a common indexing and cell, with a non-isomorphous sweep left out and reported; `--sweeps separate` processes each sweep on its own. Bruker `.sfrm` frames and imgCIF files with a full goniometer axis chain are read.
* Rugnux: More robust rotation processing - a retry with a more sensitive spot finder when no lattice is found, a self-consistent detector distance, long axes and doubled cells tested as hypotheses, a `-C` supercell multiple stepped down, and each ice ring merged, down-weighted or rejected on its own.
* Rugnux: Serial stills are merged with a partiality-aware error model, reported as `ERROR_MODEL_A/B/C` with no ISa or R_merge/R_meas/R_pim; runs without `-S` have an overall intensity scale about 0.86-0.88 times that of earlier versions, with unchanged statistics. A second crystal form is left out of the merge and reported, the indexing ambiguity is resolved more reliably, and `--model` no longer influences processing.
* Rugnux: The reported CC1/2 is the standard unweighted one, which can be lower than before on sweeps with weak frames; ISa comes with a 95% interval (`ISA_LOW`/`ISA_HIGH`).
* Rugnux: Model refinement adds anisotropic/TLS, local NCS and twin refinement where R-free supports them; building waters and relabelling ions is now off by default (`--refine-solvent` turns it on).
* NXmx: A detector of several modules is written as `module_0` ... `module_N` only, so DIALS reads each module as its own panel.
* Other: JPEG previews use a bundled encoder (libjpeg-turbo no longer needed), Rugnux prints how to cite it, and the release archives contain the HTML documentation.

Reviewed-on: #92
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-11-02 12:05:20 +01:00

67 lines
3.4 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// The device half of ModelStructureFactorsGPU (ModelStructureFactorsGPU.h). The host half works out with
// gemmi - which stays out of nvcc - everything that depends on the cell, the group and the resolution, and
// per evaluation the atoms' densities and positions; this half grids, transforms and composes. CUDA builds
// only.
#include <array>
#include <cstddef>
#include <memory>
#include <vector>
#include "ModelDensityGPU.h"
#include "ModelMaskGPU.h"
// Everything an engine needs that does not depend on the model's coordinates.
struct ModelStructureFactorsGPUSetup {
ModelDensityGrid grid; // the structure-factor grid, u fastest
ModelDensityGrid mask_grid; // the bulk-solvent mask's (SolventMaskGrid, ModelGrid.h): `grid`, or finer
double volume = 0;
// The group's operators as gemmi holds them: rot (row-major) and tran, in units of 1 / den.
std::vector<std::array<int, 12>> sym_ops;
int den = 24;
std::vector<ModelMaskOp> mask_ops; // every operator with every centring vector
std::vector<std::array<int, 3>> rows; // the reflections computed, in the order they come back
std::vector<double> row_scale; // n_cen * prepare_asu_data()'s unblur, per row
size_t max_atoms = 0, max_pairs = 0;
// The largest map MapFromFPhi() will be given: points of the real grid, and of its half-l transform.
size_t map_points = 0, map_complex_points = 0;
};
struct ModelStructureFactorsGPUEngineImpl;
class ModelStructureFactorsGPUEngine {
public:
// Every call names its device and leaves the calling thread's current device as it found it.
// The device's total memory.
static size_t TotalMemory(int device);
// The cuFFT work area the structure factors' and the mask's r2c, and a map of (nu, nv, nw)'s c2r, take on `device`.
static size_t FFTWorkBytes(int device, const ModelStructureFactorsGPUSetup &setup, int map_nu, int map_nv,
int map_nw);
// The bytes an engine for `setup` reserves on the device, given its cuFFT work area.
static size_t DeviceBytes(const ModelStructureFactorsGPUSetup &setup, size_t fft_work_bytes);
ModelStructureFactorsGPUEngine(int device, const ModelStructureFactorsGPUSetup &setup, size_t fft_work_bytes);
~ModelStructureFactorsGPUEngine();
// F_calc and F_mask at the rows for one set of atoms: each atom's density, its grid position
// (fractional times the grid size, wrapped into [0, n); the 4th number is not read) and the atoms of
// the bulk-solvent mask. Both come back as (re, im) per row.
void Compute(const std::vector<ModelDensityAtom> &atoms, const std::vector<std::array<float, 4>> &pos,
const std::vector<ModelMaskAtom> &mask_atoms, std::vector<std::array<float, 2>> &fcalc,
std::vector<std::array<float, 2>> &fmask);
// The real-space map rho(x) = 1/V sum F exp(-2 pi i h.x) of a half-l coefficient grid in gemmi's ZYX
// order - h slowest, l fastest and halved: nu * nv * (nw / 2 + 1) complex numbers, (re, im)
// interleaved, NaN read as zero - into `map`, nu * nv * nw floats with x fastest.
void Map(int nu, int nv, int nw, double volume, const float *coefficients, float *map);
private:
std::unique_ptr<ModelStructureFactorsGPUEngineImpl> impl_;
};