![]() ![]() r <= s - r is a subregion of s.Ĭonstraints are most frequently seen in the where clause of a task or field space. The supported constraints are disjointness ( *) and subregion ( <=). Constraints are checked at compile time and must be satisfied by the caller. ConstraintsĬonstraints specify the desired relationships between regions. Relaxed mode allows marked tasks to run concurrently with no restrictions.Ĭoherence modes are most frequently seen in the where clause of a task. This guarantees that the regions in question behave with shared memory semantics, similar to pthreads, etc. Simultaneous mode allows tasks to run concurrently as long as they use the same physical instance for all simultaneous regions. Atomicity is provided at the level of a task. Regent supports four coherence modes: exclusive ( r ) atomic ( r ) simultaneous ( r ) relaxed ( r )Įxclusive mode (the default) guarantees that tasks will execute in a manner that preserves the original sequential semantics of the code.Ītomic mode allows tasks to be reordered in a manner that preserves serializability, similar to a transaction-based system. Coherence ModesĬoherence modes specify a task’s expectations of isolation with respect to sibling tasks on the marked regions. Privileges are most frequently seen in the where clause of a task. reads ( r ) writes ( r ) reduces ( r ) - for op in +, *, -, /, min, max Note that privileges in general apply only to region-typed, and not immediate arguments passed by-value (such as int, float, and ptr data types). Reductions allow the application of certain commutative operators to regions. For example, reads is required in order to read from a region argument, and writes is required to modify a region. Privileges describe how a task interacts with region-typed arguments. At this time, the runtime is not reentrant, so even if the call did return, it would still not be possible to launch another top-level task. The call does not return, and is typically placed at the end of a Regent source file. This task becomes the top-level task in the Regent program, and may call other tasks as desired. Instead, a Regent program may begin execution of tasks by calling regentlib.start with a task argument. Regent programs execute in a top-level Lua/Terra context, but Regent tasks cannot be called from Lua/Terra. end - Task with privileges, coherence modes, and constraints. Unlike traditional functions, tasks must explicitly specify any interactions with the calling context through privileges, coherence modes, and constraints. Tasks are similar to functions in most other programming languages: tasks take arguments and (optionally) return a value, and contain a body of statements which execute top-to-bottom. Tasks are the fundamental unit of execution in Regent. ![]() The same principle applies to process-local data such as file descriptors: they are ok to use within a task but should not be passed between tasks. As long as pointers stay within a task, it is ok to use raw pointers (and traditional C APIs like malloc and free). Regent may execute tasks in a distributed environment, so a pointer created in one task might not be valid in another. In general, use Terra’s raw pointer types ( &T) with caution. The method call operator o:f() does not automatically dereference Regent’s ptr type.The following Terra features are not supported in Regent: For example, Lua variables referenced in Regent tasks are specialized prior to type checking, and are effectively constant from the perspective of Regent. ![]() Most Terra language features can also be used in Regent tasks, and compilation of Regent programs proceeds similarly to Terra. end return f, g end local a, b = make_fb ( 10 ) - Call the Lua function to create local c, d = make_fb ( 20 ) - specialized versions of the functions. return x + f ( y ) + z - Call the local Terra function. return x + y + z end local task g ( y : int ) - Define a local Regent task. local terra f ( y : int ) - Define a local Terra function. function make_fg ( z ) - Define a Lua function. For example: local x = 5 - Define a Lua variable (constant from the perspective of Regent). The top-level of a Regent source file executes in a Lua/Terra context, and Lua, Terra, and Regent constructs can be freely mixed at this level. This loads the Regent compiler and enables hooks to start Regent on certain keywords ( task and fspace). Every Regent source file must therefore start with: import "regent" Regent is implemented as a Terra language extension.
0 Comments
Leave a Reply. |