DotMP
Package Functions | Properties | Static Private Attributes | List of all members
DotMP.WorkShare Class Reference

Contains all relevant information about a parallel for loop. Contains a collection of Thr objects, the loop's start and end iterations, the chunk size, the number of threads, and the number of threads that have completed their work. More...

Collaboration diagram for DotMP.WorkShare:
Collaboration graph
[legend]

Package Functions

 WorkShare (uint num_threads, Thread[] threads, int start, int end, uint chunk_size, Operations? op, IScheduler schedule)
 The constructor for a WorkShare object. More...
 
 WorkShare ()
 Default constructor. More...
 
void AddReductionValue (dynamic value)
 Add a value to reduction_list. More...
 
void SetLocal< T > (ref T local)
 Sets the local variable to the appropriate value based on the operation for parallel for reduction loops. For addition and subtraction, the initial starting value is 0. For multiplication, the initial starting value is 1. For binary And, the initial starting value is the bitwise negation of 0. For binary Or and Xor, the initial starting value is 0. For boolean And, the initial starting value is true. For boolean Or, the initial starting value is false. For min, the initial starting value is int.MaxValue. For max, the initial starting value is int.MinValue. More...
 
void PerformLoop< T > (ForAction< T > forAction)
 Performs a parallel for loop according to the scheduling policy provided. More...
 

Properties

int working_iter [get]
 Get Thr object based on current thread ID. More...
 
int start [get]
 Getter and setter for the singleton integer WorkShare.start_pv. More...
 
int end [get, private set]
 The ending iteration of the parallel for loop, exclusive. More...
 
uint chunk_size [get, private set]
 Getter and setter for singleton uint WorkShare.chunk_size_pv. More...
 
uint num_threads [get, private set]
 The number of threads to be used in the parallel for loop. More...
 
Operationsop [get, private set]
 The operation to be performed if doing a reduction. More...
 
List< dynamic > reduction_values [get]
 Getter for WorkShare.reduction_list. More...
 
IScheduler schedule [get, private set]
 Getter and setter for singleton object WorkShare.schedule_pv. More...
 
bool in_for [get, set]
 Getter and setter for this thread's value in WorkShare.in_for_pv. More...
 

Static Private Attributes

static Thread[] threads
 The threads to be used in the parallel for loop. More...
 
static int[] working_iters
 The working iterations of each thread. More...
 
static volatile int start_pv
 The starting iteration of the parallel for loop, inclusive. More...
 
static uint chunk_size_pv
 The chunk size to be used with the selected scheduler. More...
 
static volatile List< dynamic > reduction_list
 The list of reduction variables from each thread. More...
 
static IScheduler schedule_pv
 The schedule to be used in the parallel for loop. More...
 
static bool[] in_for_pv
 Booleans per-thread to check if we're currently in a Parallel.For or Parallel.ForReduction<T>. More...
 

Detailed Description

Contains all relevant information about a parallel for loop. Contains a collection of Thr objects, the loop's start and end iterations, the chunk size, the number of threads, and the number of threads that have completed their work.

Constructor & Destructor Documentation

◆ WorkShare() [1/2]

DotMP.WorkShare.WorkShare ( uint  num_threads,
Thread[]  threads,
int  start,
int  end,
uint  chunk_size,
Operations op,
IScheduler  schedule 
)
inlinepackage

The constructor for a WorkShare object.

Parameters
num_threadsThe number of threads in the WorkShare.
threadsThe Thread[] array of threads.
startStarting iteration, inclusive.
endEnding iteration, exclusive.
chunk_sizeThe chunk size to use.
opThe operation for reduction, null if not a reduction.
scheduleThe Parallel.Schedule to use.

◆ WorkShare() [2/2]

DotMP.WorkShare.WorkShare ( )
inlinepackage

Default constructor.

Member Function Documentation

◆ AddReductionValue()

void DotMP.WorkShare.AddReductionValue ( dynamic  value)
inlinepackage

Add a value to reduction_list.

Parameters
valueThe value to add to reduction_list.

◆ PerformLoop< T >()

void DotMP.WorkShare.PerformLoop< T > ( ForAction< T >  forAction)
inlinepackage

Performs a parallel for loop according to the scheduling policy provided.

Template Parameters
TThe type of reductions, if applicable.
Parameters
forActionThe function to be executed.
Exceptions
InternalSchedulerExceptionThrown if the internal schedulers throw an exception.


◆ SetLocal< T >()

void DotMP.WorkShare.SetLocal< T > ( ref T  local)
inlinepackage

Sets the local variable to the appropriate value based on the operation for parallel for reduction loops. For addition and subtraction, the initial starting value is 0. For multiplication, the initial starting value is 1. For binary And, the initial starting value is the bitwise negation of 0. For binary Or and Xor, the initial starting value is 0. For boolean And, the initial starting value is true. For boolean Or, the initial starting value is false. For min, the initial starting value is int.MaxValue. For max, the initial starting value is int.MinValue.

Template Parameters
TThe type of the local variable.
Parameters
localThe local variable to be set.

Member Data Documentation

◆ chunk_size_pv

uint DotMP.WorkShare.chunk_size_pv
staticprivate

The chunk size to be used with the selected scheduler.

◆ in_for_pv

bool [] DotMP.WorkShare.in_for_pv
staticprivate

Booleans per-thread to check if we're currently in a Parallel.For or Parallel.ForReduction<T>.

◆ reduction_list

volatile List<dynamic> DotMP.WorkShare.reduction_list
staticprivate

The list of reduction variables from each thread.

◆ schedule_pv

IScheduler DotMP.WorkShare.schedule_pv
staticprivate

The schedule to be used in the parallel for loop.

◆ start_pv

volatile int DotMP.WorkShare.start_pv
staticprivate

The starting iteration of the parallel for loop, inclusive.

◆ threads

Thread [] DotMP.WorkShare.threads
staticprivate

The threads to be used in the parallel for loop.

◆ working_iters

int [] DotMP.WorkShare.working_iters
staticprivate

The working iterations of each thread.

Property Documentation

◆ chunk_size

uint DotMP.WorkShare.chunk_size
getprivate setpackage

Getter and setter for singleton uint WorkShare.chunk_size_pv.

◆ end

int DotMP.WorkShare.end
getprivate setpackage

The ending iteration of the parallel for loop, exclusive.

◆ in_for

bool DotMP.WorkShare.in_for
getsetpackage

Getter and setter for this thread's value in WorkShare.in_for_pv.

◆ num_threads

uint DotMP.WorkShare.num_threads
getprivate setpackage

The number of threads to be used in the parallel for loop.

◆ op

Operations? DotMP.WorkShare.op
getprivate setpackage

The operation to be performed if doing a reduction.

◆ reduction_values

List<dynamic> DotMP.WorkShare.reduction_values
getpackage

◆ schedule

IScheduler DotMP.WorkShare.schedule
getprivate setpackage

Getter and setter for singleton object WorkShare.schedule_pv.

◆ start

int DotMP.WorkShare.start
getpackage

Getter and setter for the singleton integer WorkShare.start_pv.

◆ working_iter

int DotMP.WorkShare.working_iter
getpackage

Get Thr object based on current thread ID.


The documentation for this class was generated from the following file: