Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tshan_k_
Beginner
82 Views

Haswell TSX using RTM (beginner student)

Jump to solution

Hello,

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++)  {

        counter++;

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

    }

    _xend();

}

    

else

    

    printf("did not work\n");

}

Tags (1)
0 Kudos
1 Solution
le_g_1
New Contributor I
82 Views

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.

View solution in original post

3 Replies
le_g_1
New Contributor I
83 Views

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.

View solution in original post

jimdempseyatthecove
Black Belt
82 Views

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

tshan_k_
Beginner
82 Views

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

Reply