Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Function Prototype and Macro Definitions

$
0
0

Function Prototype and Macro Definitions for RTM

The following function prototypes are included in the immintrin.h header file:

unsigned int _xbegin(void); 
void _xend(void); 
void _xabort(const unsigned int imm); 
unsigned char _xtest(void); 
 

The following macro definitions are included in the immintrin.h header file:

#define _XBEGIN_STARTED (~0u) 
#define _XABORT_EXPLICIT (1 << 0) 
#define _XABORT_RETRY (1 << 1) 
#define _XABORT_CONFLICT (1 << 2) 
#define _XABORT_CAPACITY (1 << 3) 
#define _XABORT_DEBUG (1 << 4) 
#define _XABORT_NESTED (1 << 5)

Note

The following function Macros are not included in immintrin.h header file. Users can consider defining and using them in applications as necessary.

For the HW with RTM support

#define __try_transaction(x) if ((x =_xbegin()) == _XBEGIN_STARTED)   
#define __try_else _xend() } else
#define __transaction_abort(c) _xabort(c)

For the HW with no RTM support

#define __try_transaction(x) if (0) {
#define __try_else } else
#define __transaction_abort(c)

x is an unsigned integer type local variable for programmers to access RTM transaction abort code and holds the return value of _xbegin(). c is an unsigned integer compile-time constant value that is returned in the upper bits of x when _xabort(c) is executed.

A usage sample code of macros

 foo() { // user macros 
int status; 
__try_transaction (status) { 
,,, ,,, ,,, 
transaction code …. 
 } 
__try_else { 
if (status & _XABORT_CONFLICT) { 
 … code 
}
}
} 

Pseudo-ASM code

foo() { or eax 0xffffffff 
xbegin L1 L1: mov status, eax 
cmp eax 0xffffffff jnz 
L2 transaction code 

// when abort happens, HW restarts from L1 
xend jmp L3 L2: abort 
handler code L3: ret 
} 

The compiler will convert the macros to the instruction sequence with a proper branching for speculative execution path and alternative execution path.

The above example is similar to the usage example, except __try_transaction and __try_else macros are used instead of RTM intrinsic functions.

Inglés

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>