Struct dslab_compute::multicore::Compute
source · pub struct Compute { /* private fields */ }Expand description
Models computing resource with multiple cores which supports execution of parallel tasks.
In this model, the computation request can specify the minimum and maximum number of used cores, and provide a function which defines the dependence of parallel speedup on the number of used cores. Each core can only be used by one computation. The cores allocation for each computation is computed upon the request arrival and is not changed afterwards. This model also supports the manual allocation and release of cores and memory.
Implementations§
source§impl Compute
impl Compute
sourcepub fn new(speed: f64, cores: u32, memory: u64, ctx: SimulationContext) -> Self
pub fn new(speed: f64, cores: u32, memory: u64, ctx: SimulationContext) -> Self
Creates a new computing resource.
sourcepub fn cores_total(&self) -> u32
pub fn cores_total(&self) -> u32
Returns the total number of cores.
sourcepub fn cores_available(&self) -> u32
pub fn cores_available(&self) -> u32
Returns the number of available cores.
sourcepub fn memory_total(&self) -> u64
pub fn memory_total(&self) -> u64
Returns the total amount of memory.
sourcepub fn memory_available(&self) -> u64
pub fn memory_available(&self) -> u64
Returns the amount of available memory.
sourcepub fn min_compute_time(
&self,
flops: f64,
min_cores: u32,
max_cores: u32,
cores_dependency: CoresDependency,
) -> Result<f64, &str>
pub fn min_compute_time( &self, flops: f64, min_cores: u32, max_cores: u32, cores_dependency: CoresDependency, ) -> Result<f64, &str>
Returns the minimum compute time for a workload with given flops, cores and cores dependency.
sourcepub fn fraction_done(&self, comp_id: EventId) -> Result<f64, &str>
pub fn fraction_done(&self, comp_id: EventId) -> Result<f64, &str>
Returns workload fraction done for a given computation.
sourcepub fn run(
&mut self,
flops: f64,
memory: u64,
min_cores: u32,
max_cores: u32,
cores_dependency: CoresDependency,
requester: Id,
) -> u64
pub fn run( &mut self, flops: f64, memory: u64, min_cores: u32, max_cores: u32, cores_dependency: CoresDependency, requester: Id, ) -> u64
Starts computation with given parameters and returns computation id.
sourcepub fn cancel_computation(&mut self, comp_id: u64)
pub fn cancel_computation(&mut self, comp_id: u64)
Cancels computation.
sourcepub fn preempt_computation(&mut self, comp_id: u64)
pub fn preempt_computation(&mut self, comp_id: u64)
Preempts computation which is currently running.
sourcepub fn resume_computation(&mut self, comp_id: u64)
pub fn resume_computation(&mut self, comp_id: u64)
Resumes computation which has been preempted.
sourcepub fn allocate(&mut self, cores: u32, memory: u64, requester: Id) -> u64
pub fn allocate(&mut self, cores: u32, memory: u64, requester: Id) -> u64
Requests resource allocation with given parameters and returns allocation id.
sourcepub fn deallocate(&mut self, cores: u32, memory: u64, requester: Id) -> u64
pub fn deallocate(&mut self, cores: u32, memory: u64, requester: Id) -> u64
Requests resource deallocation with given parameters and returns deallocation id.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Compute
impl !RefUnwindSafe for Compute
impl !Send for Compute
impl !Sync for Compute
impl Unpin for Compute
impl !UnwindSafe for Compute
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.