Haswell TSX using RTM (beginner student)

Haswell TSX using RTM (beginner student)


I am just getting introduced into haswell's TSX infrastructure using RTM. I have downloaded the rtm.h header files from online and i tried producing a simple counter. Unfortunately every time i compile and run the program, the _xbegin function does not execute the transaction inside.  I would be greatly appreciated for your help. thanks

#include <stdio.h>

#include <stdlib.h>

#include "rtm.h"

void main(){

    int N=5;

    int i;

    int status;

    int counter = 0;

    status = _xbegin();

if (status == _XBEGIN_STARTED)


    for (i=0; i<N ; i++)  {


        printf("counter value: %d\n", counter);







    printf("did not work\n");


Downloadtext/x-chdr rtm.h1.71 KB
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

You should not use print inside a transactional region. I/O is  unfriendly instruction. When the transaction is aborted,  the program goes to the else statement.

FWIW placing a break point inside a transactional region will abort the transaction. Debug your code as a critical section, then convert to TSX or RTM.

Jim Dempsey

thank you le g. and jimdempseyatthecove when i put the printf function after the _xend the transaction works. thanks again for your quick help

Leave a Comment

Please sign in to add a comment. Not a member? Join today