User`s guide

Cray XMT Programming Environment Users Guide
3.2.2 Intrinsic Functions
Cray provides intrinsic functions for the Cray XMT system that allow direct access to
machine operations from high-level languages. You can find a list of the C intrinsic
functions and the machine functions in the
mta_intrinsics(3) man page. The
C intrinsic function names use the name of the machine operation and add a prefix
of MTA_. So, for example, the machine operation named FLOAT_ROUND becomes
the C intrinsic function named MTA_FLOAT_ROUND. When you use an intrinsic
function, it calls its associated machine operation to perform the task at the processor
level using assembly language. The result of a machine operation is passed back and
becomes the return value of the intrinsic function.
For parameters, when the assembly language version of an instruction names two
input registers and an output register, the associated intrinsic function has only two
input parameters and returns a result. For example, the machine operation that you
use to multiply bit matrices, (BIT_MAT_OR
tuv), uses the intrinsic C function
_int64 MTA_BIT_MAT_OR (_int64 u, _int64 v) where the t parameter
in the machine operation becomes the return value for MTA_BIT_MAT_OR and the
u and v parameters are the operands. Invoke this intrinsic function by using the
following command:
t = MTA_BIT_MAT_OR(u, v);
For the previous statement, declare t, u, and v as integer variables by using the
_int64 data type. The intrinsic functions use the _int64 data type for 64-bit
signed integers and the _uint64 data type for 64-bit unsigned integers.
The intrinsic functions that may be most useful are the bit matrix arithmetic
functions. For example, if you want to count 1-bits or 0-bits, use the
MTA_BIT_RIGHT_ONE, MTA_BIT_LEFT_ONE, MTA_BIT_RIGHT_ZERO,or
MTA_BIT_LEFT_ZERO intrinsic functions. You can use the MTA_BIT_OR and
MTA_BIT_AND intrinsic functions to perform bitwise OR and AND operations.
Intrinsic functions support most machine operations that use signed or unsigned
integers (int), floating-point numbers (float), or bit vectors (bit) as variables.
If you do not use a constant argument where required, it results in an unresolved
reference to the intrinsic function at link time. For example, the intrinsic
MTA_TEST_CC requires a compile-time constant for its second parameter. If you
supply a variable instead, the compiler issues a warning and the invocation is
compiled as a call, resulting in a link-time failure.
3.3 Adding Synchronization to an Application
The tasks in this section explain how to add synchronization in your application.
24 S247920