intel RTM
Xin Tong
trent.tong@gmail.com
Thu Feb 5 18:52:00 GMT 2015
I ran into problems compiling this intel restricted transactional
memory test case with gcc 4.9.1. Intel ICC compiles the test case fine
with icc -O3 test-intelrtm.c -lpthread
Trent
Thanks,
#include <stdio.h>
#include <pthread.h>
#include <immintrin.h> /* _XBEGIN_START */
#define ARRAY_SIZE 1024
#define TESTTHREAD_COUNT 32
/* lock for atomic access to the testarray */
static pthread_mutex_t arraylock;
static pthread_t* threadarray;
static int testarray[ARRAY_SIZE];
static void increment_func(void* arg) {
int i;
long int threadnum = (long int)arg;
unsigned int status;
if ((status = _xbegin ()) == _XBEGIN_STARTED){
/* test _xtest() and _xabort(). fallback path for odd-num thread */
if (_xtest() && (threadnum % 2)) _xabort(_XABORT_EXPLICIT);
for (i = 0; i < ARRAY_SIZE; ++i) testarray[i] ++;
_xend();
} else {
/* fallback path. hold array lock */
pthread_mutex_lock(&arraylock);
for (i = 0; i < ARRAY_SIZE; ++i) testarray[i] ++;
/* release array lock */
pthread_mutex_unlock(&arraylock);
}
}
bash-4.1$ gcc test-intelrtm.c -lpthread
test-intelrtm.c: In function ‘run_test’:
test-intelrtm.c:44:82: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
pthread_create(&threadarray[i], NULL, (void
*(*)(void*))increment_func, (void*)i);
^
In file included from
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/immintrin.h:65:0,
from test-intelrtm.c:12:
test-intelrtm.c: In function ‘increment_func’:
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/rtmintrin.h:50:1:
error: inlining failed in call to always_inline ‘_xbegin’: target
specific option mismatch
_xbegin (void)
^
test-intelrtm.c:25:9: error: called from here
if ((status = _xbegin ()) == _XBEGIN_STARTED){
^
In file included from
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/immintrin.h:67:0,
from test-intelrtm.c:12:
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/xtestintrin.h:41:1:
error: inlining failed in call to always_inline ‘_xtest’: target
specific option mismatch
_xtest (void)
^
test-intelrtm.c:27:14: error: called from here
if (_xtest() && (threadnum % 2)) _xabort(_XABORT_EXPLICIT);
^
In file included from
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/immintrin.h:65:0,
from test-intelrtm.c:12:
/site/sc/rdrive/ref/gcc/4.9.1/rhel60/efi2/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include/rtmintrin.h:61:1:
error: inlining failed in call to always_inline ‘_xend’: target
specific option mismatch
_xend (void)
^
test-intelrtm.c:29:10: error: called from here
_xend();
^
bash-4.1$ gcc --version
gcc (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
More information about the Gcc-help
mailing list