class gpr::linalg::ProbeExecutor

Overview

#include <ProbeExecutor.h>
 
class ProbeExecutor {
public:
    // construction
 
    ProbeExecutor();
 
    // methods
 
    Eigen::VectorXd run(int n_probes, const std::function<double(int)>& probe_fn, KernelInverse::Kind kind, const MpiContext& ctx) const;
};

Detailed Documentation

Methods

Eigen::VectorXd run(int n_probes, const std::function<double(int)>& probe_fn, KernelInverse::Kind kind, const MpiContext& ctx) const

Run n_probes probe evaluations under the dispatch policy implied by kind, against the MPI context ctx, and return the global result vector. The result vector has length n_probes on every rank.

Performance contract: the std::function<double(int)> parameter is type-erased; lambdas larger than the SBO threshold (~24-32 bytes on libstdc++) heap-allocate on construction. Callers should construct the std::function ONCE outside the loop and reuse it, not re-bind on every probe. The probe lambda itself is invoked n_probes / nprocs times under RankLocal kind, n_probes times under Distributed kind.

Parameters:

n_probes

Total number of probes to evaluate. Must be >= 0.

probe_fn

Callable with signature double(int) returning the scalar contribution of probe idx (in the range ```` [0, n_probes)). May return NaN to signal failure; the executor will then return a vector of NaN on every rank.

kind

Dispatch policy. RankLocal triggers round-robin partitioning + Allreduce-SUM. Distributed runs every probe on every rank with no Allreduce.

ctx

MPI context. Use MpiContext::local() for the single-process path (always available) or MpiContext::world() under the ScaLAPACK build.

Returns:

The n_probes -element vector of probe values, identical on every rank.