DotMP
|
The main class of DotMP. Contains all the main methods for parallelism. For users, this is the main class you want to worry about, along with Lock, Shared, Atomic, and GPU. More...
Static Public Member Functions | |
static void | For (int start, int end, Action< int > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a for loop inside a parallel region. A for loop created with For inside of a parallel region is executed in parallel, with iterations being distributed among the threads, and potentially out-of-order. A schedule is provided to inform the runtime how to distribute iterations of the loop to threads. Available schedules are specified by the Schedule enum, and have detailed documentation in the Iter class. Acts as an implicit Barrier(). More... | |
static void | ForCollapse ((int, int) firstRange,(int, int) secondRange, Action< int, int > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForCollapse ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange, Action< int, int, int > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForCollapse ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange,(int, int) fourthRange, Action< int, int, int, int > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForCollapse ((int, int)[] ranges, Action< int[]> action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForReduction< T > (int start, int end, Operations op, ref T reduce_to, ActionRef< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a for loop inside a parallel region with a reduction. This is similar to For(), but the reduction allows multiple threads to reduce their work down to a single variable. Using ForReduction<T> allows the runtime to perform this operation much more efficiently than a naive approach using the Locking or Atomic classes. Each thread gets a thread-local version of the reduction variable, and the runtime performs a global reduction at the end of the loop. Since the global reduction only involves as many variables as there are threads, it is much more efficient than a naive approach. Acts as an implicit Barrier(). More... | |
static void | ForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange, Operations op, ref T reduce_to, ActionRef2< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange, Operations op, ref T reduce_to, ActionRef3< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange,(int, int) fourthRange, Operations op, ref T reduce_to, ActionRef4< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ForReductionCollapse< T > ((int, int)[] ranges, Operations op, ref T reduce_to, ActionRefN< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops. More... | |
static void | ParallelRegion (Action action, uint? num_threads=null) |
Creates a parallel region. The body of a parallel region is executed by as many threads as specified by the num_threads parameter. If the num_threads parameter is absent, then the runtime checks if SetNumThreads has been called. If so, it will use that many threads. If not, the runtime will try to use as many threads as there are logical processors. More... | |
static void | ParallelFor (int start, int end, Action< int > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel for loop. Contains all of the parameters from ParallelRegion() and For(). This is simply a convenience method for creating a parallel region and a for loop inside of it. More... | |
static void | ParallelForReduction< T > (int start, int end, Operations op, ref T reduce_to, ActionRef< T > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel for loop with a reduction. Contains all of the parameters from ParallelRegion() and ForReduction<T>(). This is simply a convenience method for creating a parallel region and a for loop with a reduction inside of it. More... | |
static void | ParallelForCollapse ((int, int) firstRange,(int, int) secondRange, Action< int, int > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop. More... | |
static void | ParallelForCollapse ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange, Action< int, int, int > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop. More... | |
static void | ParallelForCollapse ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange,(int, int) fourthRange, Action< int, int, int, int > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop. More... | |
static void | ParallelForCollapse ((int, int)[] ranges, Action< int[]> action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop. More... | |
static void | ParallelForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange, Operations op, ref T reduce_to, ActionRef2< T > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it. More... | |
static void | ParallelForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange, Operations op, ref T reduce_to, ActionRef3< T > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it. More... | |
static void | ParallelForReductionCollapse< T > ((int, int) firstRange,(int, int) secondRange,(int, int) thirdRange,(int, int) fourthRange, Operations op, ref T reduce_to, ActionRef4< T > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it. More... | |
static void | ParallelForReductionCollapse< T > ((int, int)[] ranges, Operations op, ref T reduce_to, ActionRefN< T > action, IScheduler schedule=null, uint? chunk_size=null, uint? num_threads=null) |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it. More... | |
static void | Sections (params Action[] actions) |
Creates a sections region. Sections allows for the user to submit multiple, individual tasks to be distributed among threads in parallel. In parallel, each thread active will dequeue a callback and execute it. This is useful if you have lots of individual tasks that need to be executed in parallel, and each task requires its own lambda. Acts as an implicit Barrier(). More... | |
static TaskUUID | Task (Action action, params TaskUUID[] depends) |
Enqueue a task into the task queue. Differing from OpenMP, there is no concept of parent or child tasks as of yet. All tasks submitted are treated equally in a central task queue. More... | |
static void | Taskwait (params TaskUUID[] tasks) |
Wait for selected tasks in the queue to complete, or for the full queue to empty if no tasks are specified. Acts as an implicit Barrier() if it is not called from within a task. More... | |
static TaskUUID[] | Taskloop (int start, int end, Action< int > action, uint? grainsize=null, uint? num_tasks=null, bool only_if=true, params TaskUUID[] depends) |
Creates a number of tasks to complete a for loop in parallel. If neither grainsize nor num_tasks are specified, a grainsize is calculated on-the-fly. If both grainsize and num_tasks are specified, the num_tasks parameter takes precedence over grainsize. More... | |
static void | ParallelMasterTaskloop (int start, int end, Action< int > action, uint? grainsize=null, uint? num_tasks=null, uint? num_threads=null, bool only_if=true) |
Wrapper around Parallel.ParallelRegion(), Parallel.Master(), and Parallel.Taskloop(). More... | |
static void | ParallelMaster (Action action, uint? num_threads=null) |
Wrapper around Parallel.ParallelRegion() and Parallel.Master(). More... | |
static void | MasterTaskloop (int start, int end, Action< int > action, uint? grainsize=null, uint? num_tasks=null, bool only_if=true) |
Wrapper around Parallel.Master() and Parallel.Taskloop(). More... | |
static void | ParallelSections (uint? num_threads=null, params Action[] actions) |
Creates a parallel sections region. Contains all of the parameters from ParallelRegion() and Sections(). This is simply a convenience method for creating a parallel region and a sections region inside of it. More... | |
static int | Critical (int id, Action action) |
Creates a critical region. A critical region is a region of code that can only be executed by one thread at a time. If a thread encounters a critical region while another thread is inside a critical region, it will wait until the other thread is finished. More... | |
static void | Critical (Action action, [CallerFilePath] string path="", [CallerLineNumber] int line=0) |
Creates a critical region. A critical region is a region of code that can only be executed by one thread at a time. If a thread encounters a critical region while another thread is inside a critical region, it will wait until the other thread is finished. More... | |
static void | Barrier () |
Creates a barrier. All threads must reach the barrier before any thread can continue. This is useful for synchronization. Many functions inside the Parallel class act as implicit barriers. Also acts as a memory barrier. More... | |
static int | GetNumProcs () |
Gets the number of available processors on the host system. More... | |
static void | Master (Action action) |
Creates a master region. The master region is a region of code that is only executed by the master thread. The master thread is the thread with a thread ID of 0. You can get the thread ID of the calling thread with GetThreadNum(). More... | |
static void | Single (int id, Action action) |
Creates a single region. A single region is only executed once per Parallel.ParallelRegion. The first thread to encounter the single region marks the region as encountered, then executes it. More... | |
static void | Single (Action action, [CallerFilePath] string path="", [CallerLineNumber] int line=0) |
Creates a single region. A single region is only executed once per Parallel.ParallelRegion. The first thread to encounter the single region marks the region as encountered, then executes it. More... | |
static void | Ordered (int id, Action action) |
Creates an ordered region. An ordered region is a region of code that is executed in order inside of a For() or ForReduction<T>() loop. This also acts as an implicit Critical() region. More... | |
static void | Ordered (Action action, [CallerFilePath] string path="", [CallerLineNumber] int line=0) |
Creates an ordered region. An ordered region is a region of code that is executed in order inside of a For() or ForReduction<T>() loop. This also acts as an implicit Critical() region. More... | |
static int | GetNumThreads () |
Gets the number of active threads. If not inside of a ParallelRegion(), returns 1. More... | |
static int | GetThreadNum () |
Gets the ID of the calling thread. More... | |
static void | SetNumThreads (int num_threads) |
Sets the number of threads that will be used in the next parallel region. More... | |
static int | GetMaxThreads () |
Gets the maximum number of threads that will be used in the next parallel region. More... | |
static bool | InParallel () |
Gets whether or not the calling thread is in a parallel region. More... | |
static void | SetDynamic () |
Tells the runtime to dynamically adjust the number of threads. More... | |
static bool | GetDynamic () |
Gets whether or not the runtime is dynamically adjusting the number of threads. More... | |
static void | SetNested (bool _) |
Enables nested parallelism. This function is not implemented, as nested parallelism does not exist in the current version of DotMP. There are no plans to implement nested parallelism at the moment. More... | |
static bool | GetNested () |
Gets whether or not nested parallelism is enabled. There are no plans to implement nested parallelism at the moment. More... | |
static double | GetWTime () |
Gets the wall time as a double, representing the number of seconds since the epoch. More... | |
static IScheduler | GetSchedule () |
Returns the current schedule being used in a For() or ForReduction<T>() loop. More... | |
static uint | GetChunkSize () |
Returns the current chunk size being used in a For() or ForReduction<T>() loop. More... | |
Static Package Attributes | |
static volatile bool | canceled = false |
Determines if the current threadpool has been marked to terminate. More... | |
Static Private Member Functions | |
static void | FixArgs (int start, int end, ref IScheduler sched, ref uint? chunk_size, uint num_threads) |
Fixes the arguments for a parallel for loop. If a Schedule is set to Static, Dynamic, or Guided, then the function simply calculates chunk size if none is given. If a Schedule is set to Runtime, then the function checks the OMP_SCHEDULE environment variable and sets the appropriate values. More... | |
static void | ValidateParams (int start=0, int end=0, IScheduler schedule=null, uint? num_threads=null, uint? chunk_size=null, uint? num_tasks=null, uint? grainsize=null) |
Validates all parameters passed to DotMP functions. More... | |
static string | FormatCaller (string filename, int linenum) |
Formats the caller information for determining uniqueness of a call. More... | |
static void | For< T > (int start, int end, ForAction< T > forAction, IScheduler schedule=null, uint? chunk_size=null, Operations? op=null) |
Internal handler for For. More... | |
static void | ForReduction< T > (int start, int end, Operations op, ref T reduce_to, ForAction< T > action, IScheduler schedule=null, uint? chunk_size=null) |
Internal handler for ForReduction. More... | |
Static Private Attributes | |
static volatile Dictionary< string, object > | critical_lock = new Dictionary<string, object>() |
The dictionary for critical regions. More... | |
static volatile HashSet< string > | single_thread = new HashSet<string>() |
The dictionary for single regions. More... | |
static volatile Dictionary< string, int > | ordered = new Dictionary<string, int>() |
The dictionary for ordered regions. More... | |
static volatile Barrier | barrier |
Barrier object for DotMP.Parallel.Barrier() More... | |
static volatile uint | num_threads = 0 |
Number of threads to be used in the next parallel region, where 0 means that it will be determined on-the-fly. More... | |
static ThreadLocal< int > | thread_num = new ThreadLocal<int>(() => Convert.ToInt32(Thread.CurrentThread.Name)) |
Current thread num, cached. More... | |
static ThreadLocal< uint > | task_nesting = new ThreadLocal<uint>(() => 0) |
The level of task nesting, to determine when to enact barriers and reset the DAG. More... | |
The main class of DotMP. Contains all the main methods for parallelism. For users, this is the main class you want to worry about, along with Lock, Shared, Atomic, and GPU.
|
inlinestatic |
Creates a barrier. All threads must reach the barrier before any thread can continue. This is useful for synchronization. Many functions inside the Parallel class act as implicit barriers. Also acts as a memory barrier.
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Creates a critical region. A critical region is a region of code that can only be executed by one thread at a time. If a thread encounters a critical region while another thread is inside a critical region, it will wait until the other thread is finished.
action | The action to be performed in the critical region. |
line | The line number this method was called from. |
path | The path to the file this method was called from. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Creates a critical region. A critical region is a region of code that can only be executed by one thread at a time. If a thread encounters a critical region while another thread is inside a critical region, it will wait until the other thread is finished.
THIS METHOD IS NOW DEPRECATED.
id | The ID of the critical region. Must be unique per region but consistent across all threads. |
action | The action to be performed in the critical region. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestaticprivate |
Fixes the arguments for a parallel for loop. If a Schedule is set to Static, Dynamic, or Guided, then the function simply calculates chunk size if none is given. If a Schedule is set to Runtime, then the function checks the OMP_SCHEDULE environment variable and sets the appropriate values.
start | The start of the loop. |
end | The end of the loop. |
sched | The schedule of the loop. |
chunk_size | The chunk size of the loop. |
num_threads | The number of threads to be used in the loop. |
|
inlinestatic |
Creates a for loop inside a parallel region. A for loop created with For inside of a parallel region is executed in parallel, with iterations being distributed among the threads, and potentially out-of-order. A schedule is provided to inform the runtime how to distribute iterations of the loop to threads. Available schedules are specified by the Schedule enum, and have detailed documentation in the Iter class. Acts as an implicit Barrier().
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestaticprivate |
Internal handler for For.
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
forAction | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
op | The operation to be performed in the case of reduction loops. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
fourthRange | A tuple representing the start and end of the fourth for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
ranges | A tuple representing the start and end of each of the for loops. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestaticprivate |
Formats the caller information for determining uniqueness of a call.
filename | The calling file. |
linenum | The calling line number. |
|
inlinestatic |
Creates a for loop inside a parallel region with a reduction. This is similar to For(), but the reduction allows multiple threads to reduce their work down to a single variable. Using ForReduction<T> allows the runtime to perform this operation much more efficiently than a naive approach using the Locking or Atomic classes. Each thread gets a thread-local version of the reduction variable, and the runtime performs a global reduction at the end of the loop. Since the global reduction only involves as many variables as there are threads, it is much more efficient than a naive approach. Acts as an implicit Barrier().
T | The type of the reduction. |
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestaticprivate |
Internal handler for ForReduction.
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
op | The operation to be performed in the case of reduction loops. |
reduce_to | The variable to reduce to. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
Unlike Parallel.ForCollapse, this method permits a reduction parameter.
T | The type of the reduction. |
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
Unlike Parallel.ForCollapse, this method permits a reduction parameter.
T | The type of the reduction. |
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
Unlike Parallel.ForCollapse, this method permits a reduction parameter.
T | The type of the reduction. |
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
fourthRange | A tuple representing the start and end of the fourth for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
Creates a collapsed reduction for loop inside a parallel region. A collapsed for loop can be used when you want to parallelize two or more nested for loops. Instead of only parallelizing across the outermost loop, the nested loops are flattened before scheduling, which has the effect of parallelizing across both loops. This has the effect multiplying the number of iterations the scheduler can work with, which can improve load balancing in irregular nested loops.
Unlike Parallel.ForCollapse, this method permits a reduction parameter.
T | The type of the reduction. |
ranges | A tuple representing the start and end of each of the for loops. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
TooManyIterationsException | Thrown if there are too many iterations to handle. |
|
inlinestatic |
|
inlinestatic |
Gets whether or not the runtime is dynamically adjusting the number of threads.
|
inlinestatic |
Gets the maximum number of threads that will be used in the next parallel region.
|
static |
Gets whether or not nested parallelism is enabled. There are no plans to implement nested parallelism at the moment.
|
inlinestatic |
Gets the number of available processors on the host system.
|
inlinestatic |
Gets the number of active threads. If not inside of a ParallelRegion(), returns 1.
|
inlinestatic |
|
inlinestatic |
Gets the ID of the calling thread.
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Gets the wall time as a double, representing the number of seconds since the epoch.
|
inlinestatic |
Gets whether or not the calling thread is in a parallel region.
|
inlinestatic |
Creates a master region. The master region is a region of code that is only executed by the master thread. The master thread is the thread with a thread ID of 0. You can get the thread ID of the calling thread with GetThreadNum().
action | The action to be performed in the master region. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Wrapper around Parallel.Master() and Parallel.Taskloop().
start | The start of the taskloop, inclusive. |
end | The end of the taskloop, exclusive. |
action | The action to be executed as the body of the loop. |
grainsize | The number of iterations to be completed per task. |
num_tasks | The number of tasks to spawn to complete the loop. |
only_if | Only generate tasks if true, otherwise execute loop sequentially. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates an ordered region. An ordered region is a region of code that is executed in order inside of a For() or ForReduction<T>() loop. This also acts as an implicit Critical() region.
action | The action to be performed in the ordered region. |
line | The line number this method was called from. |
path | The path to the file this method was called from. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Creates an ordered region. An ordered region is a region of code that is executed in order inside of a For() or ForReduction<T>() loop. This also acts as an implicit Critical() region.
THIS METHOD IS NOW DEPRECATED.
id | The ID of the ordered region. Must be unique per region but consistent across all threads. |
action | The action to be performed in the ordered region. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Creates a parallel for loop. Contains all of the parameters from ParallelRegion() and For(). This is simply a convenience method for creating a parallel region and a for loop inside of it.
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
fourthRange | A tuple representing the start and end of the fourth for loop. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed for loop. Contains all of the parameters from ParallelRegion() and ForCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop.
ranges | A tuple representing the start and end of each of the for loops. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel for loop with a reduction. Contains all of the parameters from ParallelRegion() and ForReduction<T>(). This is simply a convenience method for creating a parallel region and a for loop with a reduction inside of it.
T | The type of the reduction. |
start | The start of the loop, inclusive. |
end | The end of the loop, exclusive. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it.
firstRange | A tuple representing the start and end of the first for loop. |
secondRange | A tuple representing the start and end of the second for loop. |
thirdRange | A tuple representing the start and end of the third for loop. |
fourthRange | A tuple representing the start and end of the fourth for loop. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel collapsed reduction for loop. Contains all of the parameters from ParallelRegion() and ForReductionCollapse(). This is simply a convenience method for creating a parallel region and a collapsed for loop with a reduction inside of it.
ranges | A tuple representing the start and end of each of the for loops. |
op | The operation to be performed on the reduction. |
reduce_to | The variable to reduce to. |
action | The action to be performed in the loop. |
schedule | The schedule of the loop, defaulting to static. |
chunk_size | The chunk size of the loop, defaulting to null. If null, will be calculated on-the-fly. |
num_threads | The number of threads to be used in the loop, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Wrapper around Parallel.ParallelRegion() and Parallel.Master().
action | The action to be performed in the parallel region. |
num_threads | The number of threads to be used in the parallel region, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Wrapper around Parallel.ParallelRegion(), Parallel.Master(), and Parallel.Taskloop().
start | The start of the taskloop, inclusive. |
end | The end of the taskloop, exclusive. |
action | The action to be executed as the body of the loop. |
grainsize | The number of iterations to be completed per task. |
num_tasks | The number of tasks to spawn to complete the loop. |
num_threads | The number of threads to be used in the parallel region, defaulting to null. If null, will be calculated on-the-fly. |
only_if | Only generate tasks if true, otherwise execute loop sequentially. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel region. The body of a parallel region is executed by as many threads as specified by the num_threads parameter. If the num_threads parameter is absent, then the runtime checks if SetNumThreads has been called. If so, it will use that many threads. If not, the runtime will try to use as many threads as there are logical processors.
action | The action to be performed in the parallel region. |
num_threads | The number of threads to be used in the parallel region, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a parallel sections region. Contains all of the parameters from ParallelRegion() and Sections(). This is simply a convenience method for creating a parallel region and a sections region inside of it.
actions | The actions to be performed in the parallel sections region. |
num_threads | The number of threads to be used in the parallel sections region, defaulting to null. If null, will be calculated on-the-fly. |
CannotPerformNestedParallelismException | Thrown if ParallelRegion is called from within another ParallelRegion. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Creates a sections region. Sections allows for the user to submit multiple, individual tasks to be distributed among threads in parallel. In parallel, each thread active will dequeue a callback and execute it. This is useful if you have lots of individual tasks that need to be executed in parallel, and each task requires its own lambda. Acts as an implicit Barrier().
actions | The actions to be performed in the sections region. |
NotInParallelRegionException | Thrown when not in a parallel region. |
|
inlinestatic |
Tells the runtime to dynamically adjust the number of threads.
|
inlinestatic |
Enables nested parallelism. This function is not implemented, as nested parallelism does not exist in the current version of DotMP. There are no plans to implement nested parallelism at the moment.
_ | Unused. |
NotImplementedException | Is always thrown. |
|
inlinestatic |
Sets the number of threads that will be used in the next parallel region.
num_threads | The number of threads to be used in the next parallel region. |
|
inlinestatic |
Creates a single region. A single region is only executed once per Parallel.ParallelRegion. The first thread to encounter the single region marks the region as encountered, then executes it.
action | The action to be performed in the single region. |
line | The line number this method was called from. |
path | The path to the file this method was called from. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
|
inlinestatic |
Creates a single region. A single region is only executed once per Parallel.ParallelRegion. The first thread to encounter the single region marks the region as encountered, then executes it.
THIS METHOD IS NOW DEPRECATED.
id | The ID of the single region. Must be unique per region but consistent across all threads. |
action | The action to be performed in the single region. |
NotInParallelRegionException | Thrown when not in a parallel region. |
CannotPerformNestedWorksharingException | Thrown when nested inside another worksharing region. |
Enqueue a task into the task queue. Differing from OpenMP, there is no concept of parent or child tasks as of yet. All tasks submitted are treated equally in a central task queue.
action | The task to enqueue. |
depends | List of dependencies for the task. |
|
inlinestatic |
Creates a number of tasks to complete a for loop in parallel. If neither grainsize nor num_tasks are specified, a grainsize is calculated on-the-fly. If both grainsize and num_tasks are specified, the num_tasks parameter takes precedence over grainsize.
start | The start of the taskloop, inclusive. |
end | The end of the taskloop, exclusive. |
action | The action to be executed as the body of the loop. |
grainsize | The number of iterations to be completed per task. |
num_tasks | The number of tasks to spawn to complete the loop. |
only_if | Only generate tasks if true, otherwise execute loop sequentially. |
depends | List of task dependencies for taskloop. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
inlinestatic |
Wait for selected tasks in the queue to complete, or for the full queue to empty if no tasks are specified. Acts as an implicit Barrier() if it is not called from within a task.
tasks | The tasks to wait on. |
ImproperTaskwaitUsageException | Thrown if a parameter-less taskwait is called from within a thread, which leads to deadlock. |
|
inlinestaticprivate |
Validates all parameters passed to DotMP functions.
start | Start of loop. |
end | End of loop. |
schedule | Scheduler used. |
num_threads | Number of threads. |
chunk_size | Chunk size. |
num_tasks | Number of tasks. |
grainsize | Grainsize. |
InvalidArgumentsException | Thrown if any provided arguments are invalid. |
|
staticprivate |
Barrier object for DotMP.Parallel.Barrier()
|
staticpackage |
Determines if the current threadpool has been marked to terminate.
|
staticprivate |
The dictionary for critical regions.
|
staticprivate |
Number of threads to be used in the next parallel region, where 0 means that it will be determined on-the-fly.
|
staticprivate |
The dictionary for ordered regions.
|
staticprivate |
The dictionary for single regions.
|
staticprivate |
The level of task nesting, to determine when to enact barriers and reset the DAG.
|
staticprivate |
Current thread num, cached.