Skip to main content

McProgram

Struct McProgram 

Source
pub struct McProgram { /* private fields */ }

Implementations§

Source§

impl McProgram

Source§

impl McProgram

Source

pub fn evaluate_resident_with_provider( &self, cfg: McEvalConfig, provider: Arc<CudaKernelProvider>, ) -> Result<McResidentResult>

Evaluate this program with the GPU-resident engine. Returns device-resident counts plus no-host instrumentation for the measured region. Fails closed (typed ResidentRejection wrapped into [XlogError]) for programs outside the supported fragment.

Source

pub fn evaluate_resident(&self, cfg: McEvalConfig) -> Result<McResidentResult>

Convenience: evaluate with a fresh provider.

Source§

impl McProgram

Source

pub fn compile_source(source: &str) -> Result<Self>

Source

pub fn compile_source_with_gpu(source: &str, config: GpuConfig) -> Result<Self>

Source

pub fn num_vars(&self) -> usize

Source

pub fn evaluate(&self, cfg: McEvalConfig) -> Result<McResult>

Host-facing MC evaluation: runs the resident megakernel engine (Self::evaluate_gpu_device_with_provider) and then materializes the result on the host by downloading the final query/evidence counts after the measured region. The download is a host-result materialization, not part of the measured region — the no-host property belongs to the resident engine, not to this convenience wrapper. Use Self::evaluate_gpu_device when you want device-resident counts with no host download at all.

Fail-closed contract: if the resident engine rejects the program (negation, aggregates, unbounded terms, …), this returns the typed rejection error. The CPU oracle is reachable only via the explicit McEvalConfig::allow_cpu_oracle_fallback opt-in and its result is labeled McEngine::CpuOracle.

Source

pub fn evaluate_cpu(&self, cfg: McEvalConfig) -> Result<McResult>

CPU oracle / debug MC path. Downloads the full sampled-bit matrix to the host and evaluates every sampled world on a host relation store.

This is intentionally not GPU-native: it performs a large DtoH of the sample matrix and runs the deterministic core on the CPU. It exists solely as a deterministic, seed-matched oracle for validating the GPU-native device counts (the GPU sampler is shared, so for the same program/seed the two paths see identical samples). It must never be used as zero-host / GPU-native release evidence, and the acceptance matrix excludes it and the tests that call it (tests/gpu_mc_vs_cpu.rs, tests/mc.rs).

Source

pub fn evaluate_gpu(&self, cfg: McEvalConfig) -> Result<McResult>

Alias for Self::evaluate: GPU device evaluation followed by host-result materialization (final-count download after the measured region). The _gpu suffix denotes that the compute runs on the GPU — it does not imply a zero-host result, since it returns a host McResult. For the device-resident, no-host-download API use Self::evaluate_gpu_device.

Source

pub fn evaluate_gpu_device(&self, cfg: McEvalConfig) -> Result<McDeviceResult>

GPU-native device-resident MC evaluation via the resident megakernel engine ([resident]). Returns McDeviceResult with counts left on the device (no host download). The engine evaluates all worlds in a single launch with no host interaction in the measured region (no host sample loop, no per-sample/per-operator host launches or allocations, no tracked transfers, and no untracked metadata reads); see McResidentResult::no_host / McNoHostStats::is_no_host for the full measured contract.

Source

pub fn evaluate_gpu_device_with_provider( &self, cfg: McEvalConfig, provider: Arc<CudaKernelProvider>, ) -> Result<McDeviceResult>

GPU-native device-resident MC evaluation using a caller-supplied provider (enables provider/buffer reuse across calls). Static setup (arena allocation, plan upload, sampling) happens before the measured region; the measured region is a single resident-engine launch with zero host interaction — no host loop over samples or fixpoint iterations, no per-sample/per-operator host launches or device allocations, no tracked HtoD/DtoH transfers, and no untracked metadata reads. The full contract is measured by McNoHostStats (McResidentResult::no_host) and gated by tests/mc_resident.rs. Counts remain device-resident; the caller decides whether/when to download them.

Trait Implementations§

Source§

impl Clone for McProgram

Source§

fn clone(&self) -> McProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,