Build Packages / Create release (push) Successful in 8s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m11s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 10m32s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 18m26s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 22m11s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 23m32s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 25m36s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 27m28s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 28m10s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 28m10s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 29m24s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 21m45s
Build Packages / Generate python client (push) Successful in 31s
Build Packages / Build documentation (push) Successful in 1m21s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 24m2s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 29m25s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 30m27s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 27m12s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 32m20s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 33m36s
Build Packages / Unit tests (push) Successful in 2h7m18s
Build Packages / Validation Battery (push) Successful in 33m19s
* Rugnux: Stills processing needs only the unit cell and space group beyond what the file records - detector distance, beam centre, tilt, panel placement, saturation level, gain and polarisation plane are found from the images - and is up to twice as fast. * Rugnux: Stills can be indexed without a GPU, with a CPU implementation of the fast-feedback indexer (macOS, computers without a GPU). * Rugnux: Rotation and stills data are integrated in the detector's own units with one gain model, improving data from CCD detectors. * Web frontend: The Rugnux live page shows the placed model with its electron density and anomalous difference map in a Mol* viewer. Reviewed-on: #90 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
93 lines
3.7 KiB
C++
93 lines
3.7 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
#include "BraggPrediction.h"
|
|
#include "RotationColumnRange.h"
|
|
#include "../indexing/CUDAMemHelpers.h"
|
|
|
|
struct KernelConstsRot {
|
|
float det_x0, det_y0, det_x1, det_y1; // the plane the panels span (DetectorModules::PlaneBounds)
|
|
float beam_x;
|
|
float beam_y;
|
|
float coeff_const;
|
|
float one_over_wavelength;
|
|
float one_over_dmax_sq;
|
|
float mos_angle_rad;
|
|
float wedge_angle_rad;
|
|
float min_zeta;
|
|
float mosaicity_multiplier;
|
|
float bandwidth_sigma; // relative dlambda/lambda as a sigma; 0 = monochromatic
|
|
float half_wavelength_A;
|
|
// Angle-dependent sensor efficiency, reduced to the two per-dataset numbers the kernel needs:
|
|
// the optical thickness at normal incidence and the absorbed fraction there. qe_a0 = 0 leaves
|
|
// every reflection untouched (see sensor_absorption::SensorQE).
|
|
float qe_a0;
|
|
float qe_qe0;
|
|
float flight_dL; // normal-incidence air flight path in attenuation lengths; 0 = off
|
|
Coord Astar, Bstar, Cstar, S0;
|
|
Coord m1, m2, m3;
|
|
float m2_S0;
|
|
float m3_S0;
|
|
float rot[9];
|
|
char centering;
|
|
// Which l of a column the kernel walks (RotationColumnRange): phi_limit <= 0 walks them all. The
|
|
// column's b(h, k) = b0 + b_h h + b_k k and c(h, k) = c_hh h^2 + c_hk h k + c_kk k^2 + c_h h + c_k k.
|
|
double phi_limit, f_max, C_C, inv_2C_C;
|
|
double b0, b_h, b_k, c_hh, c_hk, c_kk, c_h, c_k;
|
|
};
|
|
|
|
class BraggPredictionRotGPU : public BraggPrediction {
|
|
// The device's reflections, in the order the atomics placed them.
|
|
CudaDevicePtr<Reflection> d_out;
|
|
// The rows Calc returns, ordered and selected on the device, then downloaded into h_out: pinned, so
|
|
// the download is a DMA, and from the pool, so the engine does not register and unregister a vector
|
|
// of its own. Sized for what is returned (at most output_limit), not for what was predicted.
|
|
CudaDevicePtr<Reflection> d_kept;
|
|
CudaHostPtr<Reflection> h_out;
|
|
int kept_capacity = 0;
|
|
|
|
// Sort keys and the permutation they carry, double-buffered for cub's radix sort, and its scratch.
|
|
CudaDevicePtr<uint32_t> d_key32[2];
|
|
CudaDevicePtr<uint64_t> d_key64[2];
|
|
CudaDevicePtr<int> d_index[2];
|
|
CudaDevicePtr<uint8_t> d_sort_temp;
|
|
size_t sort_temp_bytes = 0;
|
|
|
|
// Which l of each (h, k) column the kernel walks (column_range_kernel).
|
|
CudaDevicePtr<RotationColumn> d_columns;
|
|
int column_capacity = 0;
|
|
|
|
// Dedicated stream
|
|
CudaStream stream;
|
|
|
|
// Device allocations via helpers
|
|
CudaDevicePtr<KernelConstsRot> dK;
|
|
CudaDevicePtr<int> d_count;
|
|
|
|
// Host pinned buffer for async download (optional but faster)
|
|
CudaHostPtr<int> h_count;
|
|
|
|
// Order the `count` device reflections exactly as OrderOutput and TruncateToOutput would, keep the
|
|
// first min(count, output_limit) and download them into `reflections`. Returns the kept count.
|
|
int OrderAndSelect(int count, const BraggPredictionSettings &settings);
|
|
|
|
public:
|
|
explicit BraggPredictionRotGPU(int max_reflections = kPredictionCapacity);
|
|
// Waits for the stream: its pooled buffers are freed next (see CudaDevicePtr).
|
|
~BraggPredictionRotGPU() override { cudaStreamSynchronize(stream); }
|
|
|
|
protected:
|
|
void GrowCapacity(int count) override;
|
|
// Walk every l of every column, as BraggPredictionRot's flag of the same name - for the test.
|
|
bool enumerate_full_box = false;
|
|
|
|
public:
|
|
int Calc(const DiffractionExperiment &experiment,
|
|
const CrystalLattice &lattice,
|
|
const BraggPredictionSettings &settings) override;
|
|
};
|