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: NonZeroUsizeMaximum number of simultaneous compilations through this compiler.
target: TargetArchitecture used by the Loom target profile and artifact cache.
module_cache_capacity: usizeMaximum retained source modules; zero disables module caching. Eviction chooses an arbitrary entry, not the least recently used module.
processor_mode: ProcessorModeWorkgroup scheduling policy for the selected AMDGPU target.
sanitizer: SanitizerOptionsInstrumentation included in pipeline, shared compiler, and artifact identities.
Implementations§
Source§impl CompilerOptions
impl CompilerOptions
Sourcepub fn for_target(target: &Target) -> Self
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}Sourcepub fn for_stream(stream: &Stream) -> Self
pub fn for_stream(stream: &Stream) -> Self
Default compiler limits targeting the device behind stream.
Trait Implementations§
Source§impl Clone for CompilerOptions
impl Clone for CompilerOptions
Source§impl Debug for CompilerOptions
impl Debug for CompilerOptions
Auto Trait Implementations§
impl Freeze for CompilerOptions
impl RefUnwindSafe for CompilerOptions
impl Send for CompilerOptions
impl Sync for CompilerOptions
impl Unpin for CompilerOptions
impl UnsafeUnpin for CompilerOptions
impl UnwindSafe for CompilerOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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