Struct TaskArg

Source
pub struct TaskArg<'a> { /* private fields */ }
Expand description

Represents a data argument for an MCL task along with the use flags (e.g. input, output, access type etc.)

Implementations§

Source§

impl<'a> TaskArg<'a>

Source

pub fn input_slice<T>(slice: &'a [T]) -> Self

Create a new task input argument from slice

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let task = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data));
Source

pub fn input_scalar<T>(scalar: &'a T) -> Self

Create a new task input argument from scalar

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = 4;
     let task = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_scalar(&data));
Source

pub fn input_shared<T>(name: &str, size: usize) -> Self

Available on crate feature shared_mem only.

Create an new task input argument using a shared memory buffer

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();

     let num_elems = 100;
     let buffer = mcl.create_shared_buffer(mcl_rs::TaskArg::input_shared::<f32>("my_buffer",num_elems).resident(true));
     let task = mcl.task("my_kernel",1)
                   .input_shared(buffer);
Source

pub fn output_slice<T>(slice: &'a mut [T]) -> Self

Create a new task output argument from slice

Returns a new TaskArg

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let mut data = vec![0; 4];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::output_slice(&mut data));
Source

pub fn output_shared<T>(name: &str, size: usize) -> Self

Available on crate feature shared_mem only.

Create an new task output argument using a shared memory buffer

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();

     let num_elems = 100;
     let buffer = mcl.create_shared_buffer(mcl_rs::TaskArg::output_shared::<f32>("my_buffer",num_elems).resident(true));
     let task = mcl.task("my_kernel",1)
                   .output_shared(buffer);
Source

pub fn output_scalar<T>(scalar: &'a T) -> Self

Create a new task output argument from scalar

Returns a new TaskArg

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let mut data = 4;
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::output_scalar(&mut data));
Source

pub fn inout_slice<T>(slice: &'a [T]) -> Self

Create a new task input+output argument from slice

Returns a new TaskArg

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let mut data = vec![0; 4];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::inout_slice(&mut data));
Source

pub fn inout_shared<T>(name: &str, size: usize) -> Self

Available on crate feature shared_mem only.

Create an new task input+output argument using a shared memory buffer

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();

     let num_elems = 100;
     let buffer = mcl.create_shared_buffer(mcl_rs::TaskArg::inout_shared::<f32>("my_buffer",num_elems).resident(true));
     let task = mcl.task("my_kernel",1)
                   .inout_shared(buffer);
Source

pub fn inout_scalar<T>(scalar: &'a T) -> Self

Create a new task input+output argument from scalar

Returns a new TaskArg

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let mut data = 4;
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::inout_scalar(&mut data));
Source

pub fn resident(self, val: bool) -> Self

Sets the resident memory flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).resident(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);
Source

pub fn dynamic(self, val: bool) -> Self

Sets the dynamic memory flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.load_prog("my_prog",mcl_rs::PrgType::Src);
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).dynamic(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);
Source

pub fn done(self, val: bool) -> Self

Sets the done flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).done(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);
Source

pub fn invalid(self, val: bool) -> Self

Sets the invalid flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).invalid(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);
Source

pub fn read_only(self, val: bool) -> Self

Sets the read_only flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).read_only(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);
Source

pub fn write_only(self, val: bool) -> Self

Sets the write_only flag for the argument

Returns the TaskArg with the preference set

§Examples
     let mcl = mcl_rs::MclEnvBuilder::new().initialize();
     mcl.create_prog("my_prog",mcl_rs::PrgType::Src)
         .with_compile_args("-D MYDEF").load();
     let data = vec![0; 4];
     let les: [u64; 3] = [1, 1, 1];
     let pes: [u64; 3] = [1, 1, 1];
     let mcl_future = mcl.task("my_kernel", 1)
                 .arg(mcl_rs::TaskArg::input_slice(&data).write_only(true))
                 .exec(pes);
     futures::executor::block_on(mcl_future);

Trait Implementations§

Source§

impl<'a> Clone for TaskArg<'a>

Source§

fn clone(&self) -> TaskArg<'a>

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

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Default for TaskArg<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TaskArg<'a>

§

impl<'a> RefUnwindSafe for TaskArg<'a>

§

impl<'a> Send for TaskArg<'a>

§

impl<'a> Sync for TaskArg<'a>

§

impl<'a> Unpin for TaskArg<'a>

§

impl<'a> UnwindSafe for TaskArg<'a>

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.