Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

Haswell TSX using RTM (beginner student)

tshan_k_
Beginner
400 Views

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");

}

0 Kudos
1 Solution
le_g_1
New Contributor I
400 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

0 Kudos
3 Replies
le_g_1
New Contributor I
401 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.

0 Kudos
jimdempseyatthecove
Honored Contributor III
400 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

0 Kudos
tshan_k_
Beginner
400 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

0 Kudos
Reply