Struct ispc::task::Context

source ·
pub struct Context {
    pub id: usize,
    /* private fields */
}
Expand description

A list of all task groups spawned by a function in some launch context which will be sync’d at an explicit sync call or function exit.

Note: A Context is done if and only if ISPCSync has been called with its handle and all of its tasks are finished. Until ISPCSync is called on the Context’s handle more tasks could be launched.

Additionally, because we’re not really able to associate a call to ISPCAlloc with a specific Group care must be taken that the Context is not dropped until ISPCSync has been called on its handle and all Groups within have completed execution.

Fields§

§id: usize

A unique identifier for this context

Implementations§

source§

impl Context

source

pub fn new(id: usize) -> Context

Create a new list of tasks for some function with id id

source

pub fn launch( &self, total: (i32, i32, i32), data: *mut c_void, fcn: extern "C" fn(_: *mut c_void, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32) )

Add a task group for execution that was launched in this context

source

pub fn current_tasks_done(&self) -> bool

Check if all tasks currently in the task list are completed

Note: A Context is done if and only if ISPCSync has been called with its handle and all of its tasks are finished. Until ISPCSync is called on the Context’s handle more tasks could be launched. TODO: With this design we’re essentially requiring the thread waiting on the context to busy wait since we provide no condition variable to block on.

source

pub unsafe fn alloc(&self, size: usize, align: usize) -> *mut c_void

Allocate some memory for this Context’s task groups, returns a pointer to the allocated memory.

Safety

This function is unsafe as it is used to perform a raw memory allocation to be passed back to ISPC

source

pub fn iter(&self) -> ContextIter<'_>

An iterator over the current groups in the context which have remaining tasks to run on a thread. If more task groups are added before this iterator has returned None those will appear as well.

Trait Implementations§

source§

impl Debug for Context

source§

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

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

impl Drop for Context

source§

fn drop(&mut self)

Release memory for all the tasks in this context

Note: that because we’re not really able to associate a call to ISPCAlloc with a specific Group care must be taken that the Context is not dropped until ISPCSync has been called on its handle and all Groups within have completed execution.

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

§

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

§

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.