Struct DirectiveBuilder

Source
pub struct DirectiveBuilder { /* private fields */ }
Expand description

Builder for constructing DirectiveIR with a fluent API

Implementations§

Source§

impl<'a> DirectiveBuilder

Source

pub fn parallel() -> Self

Create a new builder for a parallel directive

§Example
use roup::ir::{DirectiveBuilder, Language, SourceLocation};

let directive = DirectiveBuilder::parallel()
    .default_shared()
    .build(SourceLocation::start(), Language::C);

assert!(directive.kind().is_parallel());
Source

pub fn parallel_for() -> Self

Create a new builder for a parallel for directive

Source

pub fn for_loop() -> Self

Create a new builder for a for directive

Source

pub fn task() -> Self

Create a new builder for a task directive

Source

pub fn target() -> Self

Create a new builder for a target directive

Source

pub fn teams() -> Self

Create a new builder for a teams directive

Source

pub fn new(kind: DirectiveKind) -> Self

Create a new builder for any directive kind

Source

pub fn default_shared(self) -> Self

Add a default(shared) clause

Source

pub fn default_none(self) -> Self

Add a default(none) clause

Source

pub fn default(self, kind: DefaultKind) -> Self

Add a default clause with specified kind

Source

pub fn private(self, vars: &[&'a str]) -> Self

Add a private clause

§Example
use roup::ir::{DirectiveBuilder, Language, SourceLocation};

let directive = DirectiveBuilder::parallel()
    .private(&["x", "y", "z"])
    .build(SourceLocation::start(), Language::C);
Source

pub fn firstprivate(self, vars: &[&'a str]) -> Self

Add a firstprivate clause

Source

pub fn shared(self, vars: &[&'a str]) -> Self

Add a shared clause

Source

pub fn reduction(self, operator: ReductionOperator, vars: &[&'a str]) -> Self

Add a reduction clause

§Example
use roup::ir::{DirectiveBuilder, ReductionOperator, Language, SourceLocation};

let directive = DirectiveBuilder::parallel()
    .reduction(ReductionOperator::Add, &["sum"])
    .build(SourceLocation::start(), Language::C);
Source

pub fn num_threads(self, num: i32) -> Self

Add a num_threads clause

Note: This creates an unparsed expression. For better control, use num_threads_expr() with a static string.

Source

pub fn num_threads_expr(self, expr: &'a str) -> Self

Add a num_threads clause with expression

Source

pub fn if_clause(self, condition: &'a str) -> Self

Add an if clause

Source

pub fn schedule_simple(self, kind: ScheduleKind) -> Self

Add a schedule clause

§Example
use roup::ir::{DirectiveBuilder, ScheduleKind, Language, SourceLocation};

let directive = DirectiveBuilder::for_loop()
    .schedule_simple(ScheduleKind::Static)
    .build(SourceLocation::start(), Language::C);
Source

pub fn schedule(self, kind: ScheduleKind, chunk_size: Option<&'a str>) -> Self

Add a schedule clause with chunk size expression

Source

pub fn schedule_with_modifiers( self, kind: ScheduleKind, modifiers: Vec<ScheduleModifier>, chunk_size: Option<&'a str>, ) -> Self

Add a schedule clause with modifiers

Source

pub fn collapse(self, n: &'a str) -> Self

Add a collapse clause with expression

Source

pub fn ordered(self) -> Self

Add an ordered clause

Source

pub fn ordered_n(self, n: &'a str) -> Self

Add an ordered clause with parameter

Source

pub fn nowait(self) -> Self

Add a nowait clause

Source

pub fn map(self, map_type: MapType, vars: &[&'a str]) -> Self

Add a map clause

Source

pub fn depend(self, depend_type: DependType, vars: &[&'a str]) -> Self

Add a depend clause

Source

pub fn proc_bind(self, kind: ProcBind) -> Self

Add a proc_bind clause

Source

pub fn build(self, location: SourceLocation, language: Language) -> DirectiveIR

Build the DirectiveIR

§Example
use roup::ir::{DirectiveBuilder, Language, SourceLocation};

let directive = DirectiveBuilder::parallel()
    .default_shared()
    .private(&["x"])
    .build(SourceLocation::start(), Language::C);

assert_eq!(directive.clauses().len(), 2);

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> 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, 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.