Skip to main content

CompilerOptions

Struct CompilerOptions 

Source
pub struct CompilerOptions {
    pub workers: NonZeroUsize,
    pub target: Target,
    pub module_cache_capacity: usize,
    pub processor_mode: ProcessorMode,
    pub sanitizer: SanitizerOptions,
}
Expand description

Compiler target and limits for concurrent workspaces and cached modules.

Fields§

§workers: NonZeroUsize

Maximum number of simultaneous compilations through this compiler.

§target: Target

Architecture used by the Loom target profile and artifact cache.

§module_cache_capacity: usize

Maximum retained source modules; zero disables module caching. Eviction chooses an arbitrary entry, not the least recently used module.

§processor_mode: ProcessorMode

Workgroup scheduling policy for the selected AMDGPU target.

§sanitizer: SanitizerOptions

Instrumentation included in pipeline, shared compiler, and artifact identities.

Implementations§

Source§

impl CompilerOptions

Source

pub fn for_target(target: &Target) -> Self

Default compiler limits for an explicit device target.

Examples found in repository?
examples/patch_bench.rs (line 375)
348fn main() -> Result<()> {
349    let args: Vec<_> = std::env::args().collect();
350    if args.len() < 3 || args.len() > 5 {
351        return Err(hrx::Error::Message(
352            "usage: patch_bench BASELINE_LIB CANDIDATE_LIB [pairs=30] [default|cu|wgp]".into(),
353        ));
354    }
355    let pairs = args
356        .get(3)
357        .map(|s| s.parse::<usize>())
358        .transpose()
359        .map_err(|e| hrx::Error::Message(e.to_string()))?
360        .unwrap_or(30);
361    if pairs < 30 {
362        return Err(hrx::Error::Message("at least 30 pairs are required".into()));
363    }
364    let mode = match args.get(4).map(String::as_str).unwrap_or("default") {
365        "default" => ProcessorMode::Default,
366        "cu" => ProcessorMode::ComputeUnit,
367        "wgp" => ProcessorMode::WorkgroupProcessor,
368        _ => {
369            return Err(hrx::Error::Message(
370                "mode must be default, cu or wgp".into(),
371            ));
372        }
373    };
374    let mut stream = Stream::open()?;
375    let mut options = CompilerOptions::for_target(stream.target());
376    options.processor_mode = mode;
377    let compilers = [
378        Compiler::with_options(Some(Path::new(&args[1])), options.clone())?,
379        Compiler::with_options(Some(Path::new(&args[2])), options)?,
380    ];
381    for case in [
382        attention(128, false),
383        attention(512, false),
384        gemm(false, false),
385        gemm(true, false),
386        gemm(false, true),
387        gemm(true, true),
388        conv(56, 64, 64),
389        conv(14, 256, 256),
390        conv(7, 512, 512),
391    ] {
392        let baseline = prepare(&mut stream, &compilers[0], &case, None)?;
393        let candidate = prepare(
394            &mut stream,
395            &compilers[1],
396            &case,
397            Some(baseline.buffers.clone()),
398        )?;
399        let mut arms = [baseline, candidate];
400        for arm in &mut arms {
401            for _ in 0..5 {
402                stream.launch(&mut arm.graph)?;
403                stream.synchronize()?;
404            }
405            check(&mut stream, arm, &case)?;
406        }
407        let errors = [
408            check(&mut stream, &arms[0], &case)?,
409            check(&mut stream, &arms[1], &case)?,
410        ];
411        println!(
412            "{}",
413            serde_json::json!({"case":case.name,"mode":format!("{mode:?}"),"baseline":arms[0].identity,"candidate":arms[1].identity,"max_absolute_error":errors,"tolerance":case.tolerance,"replays":32})
414        );
415        for pair in 0..pairs {
416            let mut ns = [0.0; 2];
417            for index in if pair % 2 == 0 { [0, 1] } else { [1, 0] } {
418                let start = Instant::now();
419                stream.launch(&mut arms[index].graph)?;
420                stream.synchronize()?;
421                ns[index] = start.elapsed().as_secs_f64() * 1e9 / 32.0;
422            }
423            println!(
424                "{}",
425                serde_json::json!({"case":case.name,"pair":pair,"baseline_ns":ns[0],"candidate_ns":ns[1]})
426            );
427        }
428        for arm in &mut arms {
429            stream.launch(&mut arm.graph)?;
430            stream.synchronize()?;
431            check(&mut stream, arm, &case)?;
432        }
433    }
434    Ok(())
435}
Source

pub fn for_stream(stream: &Stream) -> Self

Default compiler limits targeting the device behind stream.

Trait Implementations§

Source§

impl Clone for CompilerOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CompilerOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompilerOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<E> ResultError for E
where E: Send + Debug + Sync,

Source§

impl<T> ResultType for T
where T: Send + Clone + Sync + Debug,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more