atomic support for LEON3 platform
Hi all, Recently i am working on the atomic support for RTEMS. Our basic idea is to integrate the C11 atomic API into RTEMS. we have integrated the stdatomic.h into newlib which is used by RTEMS. And when we test the atomic ops on LEON3 platform (an important platform for RTEMS to test and verify SMP support) it posted that there is no defined functions like "__atomic_fetch_add_xx". And this is because of SPARC V7-V8 lacks of compare and swap instruction., GCC also does not support those build in ops. But for LEON3 it is a special case, it has its own casa instruction to support compare_and_swap function. So i wonder whether gcc can consider support LEON3 build in atomic ops. WeiY Best Regards
Re: atomic support for LEON3 platform
在 2013-7-23,上午5:54,Eric Botcazou 写道: >> Recently i am working on the atomic support for RTEMS. Our basic idea is to >> integrate the C11 atomic API into RTEMS. we have integrated the >> stdatomic.h into newlib which is used by RTEMS. And when we test the >> atomic ops on LEON3 platform (an important platform for RTEMS to test and >> verify SMP support) it posted that there is no defined functions like >> "__atomic_fetch_add_xx". And this is because of SPARC V7-V8 lacks of >> compare and swap instruction., GCC also does not support those build in >> ops. But for LEON3 it is a special case, it has its own casa instruction >> to support compare_and_swap function. So i wonder whether gcc can consider >> support LEON3 build in atomic ops. > > Sure, patches to that effect are welcome. This will need to be coordinated > with binutils because the assembler will very likely reject the instructions > if it is passed -Av8 as is currently done for LEON/LEON3. As a matter of > fact, > I just installed a patch to add basic LEON3 support on the trunk so almost > everything is already there as far as the compiler is concerned. > Hi Eric, do you mean that you already have a patch to solve this issue which is just not merged to mainline? If yes could you send me your patch and tell me to how enable this feature? Thank you! > -- > Eric Botcazou
Re: atomic support for LEON3 platform
在 2013-7-23,下午11:31,Eric Botcazou 写道: >> Hi Eric, do you mean that you already have a patch to solve this issue >> which is just not merged to mainline? If yes could you send me your patch >> and tell me to how enable this feature? Thank you! > > No, I only installed a patch on the trunk that adds the basic infrastructure > for a LEON3 variant of the compiler (we only had a LEON variant before). The > underlying architecture is still a strict V8 so it won't generate 'cas', but > it > will not be difficult to instruct it to do so once binutils support is there. > ok, because i am not familiar with compiler implementation. So if you can give me some references i will appreciate you very much. And by the way is there any plan to support this feature in the mainline? Best Regards WeiY > > -- > Eric Botcazou
Re: atomic support for LEON3 platform
Hi Eric, Thank you for your interesting on this feature. Best Regards WeiY 在 2013-7-24,上午1:07,Eric Botcazou 写道: >> ok, because i am not familiar with compiler implementation. So if you can >> give me some references i will appreciate you very much. And by the way is >> there any plan to support this feature in the mainline? > > OK, let's go ahead and implement the feature. We first need the binutils > side, > because a 'cas' is currently rejected by the assembler: > > eric@hermes:~/leon-elf> gcc/xgcc -Bgcc -c cas.adb -mcpu=leon3 > /tmp/ccOuqOpo.s: Assembler messages: > /tmp/ccOuqOpo.s:24: Error: Architecture mismatch on "cas". > /tmp/ccOuqOpo.s:24: (Requires v9|v9a|v9b; requested architecture is v8.) > /tmp/ccOuqOpo.s:47: Error: Architecture mismatch on "cas". > /tmp/ccOuqOpo.s:47: (Requires v9|v9a|v9b; requested architecture is v8.) > > David, how do you want to handle this on the binutils side? The compiler > currently passes -Av8 for LEON3 and I don't think that we want to pass -Av9 > instead, so we would need something in between. > > -- > Eric Botcazou
i386 __atomic_compare_exchange_n not found
Hi all, I am form RTEMS org, recently we are working on atomic support for RTEMS. The C11 stdatomic.h has been ported to RTEMS. But when i build the atomic test case for pc686 BSP it will post some error like this : /home/rtems-build/i386-build/i386-rtems4.11/c/pc686/testsuites/smptests/smpatomic07/../../../../../pc686/lib/include/rtems/score/cpustdatomic.h:278: undefined reference to `__atomic_compare_exchange_4' /home/rtems-build/i386-build/i386-rtems4.11/c/pc686/testsuites/smptests/smpatomic07/../../../../../pc686/lib/include/rtems/score/cpustdatomic.h:278: undefined reference to `__atomic_compare_exchange_4' tasks.o: In function `_Atomic_Compare_exchange_ptr': /home/rtems-build/i386-build/i386-rtems4.11/c/pc686/testsuites/smptests/smpatomic07/../../../../../pc686/lib/include/rtems/score/cpustdatomic.h:290: undefined reference to `__atomic_compare_exchange_4' /home/rtems-build/i386-build/i386-rtems4.11/c/pc686/testsuites/smptests/smpatomic07/../../../../../pc686/lib/include/rtems/score/cpustdatomic.h:290: undefined reference to `__atomic_compare_exchange_4' tasks.o:/home/rtems-build/i386-build/i386-rtems4.11/c/pc686/testsuites/smptests/smpatomic07/../../../../../pc686/lib/include/rtems/score/cpustdatomic.h:290: more undefined references to `__atomic_compare_exchange_4' follow And i have found some mail list talking about gcc has remove lock free atomic int support [1][2], is this true? or just some error caused by my toolchain? I am waiting for your reply, Thank you! [1]. http://gcc.gnu.org/ml/gcc/2012-12/msg00079.html [2]. http://www.phoronix.com/scan.php?page=news_item&px=MTI1MDU WeiY Best Regards
Re: i386 __atomic_compare_exchange_n not found
Hi Jonathan, Thank you for your reply. And about the error i encounter, do you have any advice? maybe it is caused by my toolchain not install rightly? In the standard pc686 architecture(not cross compile on RTEMS) will it encounter the similar error? WeiY Best Regards 在 2013-8-6,下午11:25,Jonathan Wakely 写道: > On 6 August 2013 15:47, Deng Hengyi wrote: >> >> And i have found some mail list talking about gcc has remove lock free >> atomic int support [1][2], is this true? or just some error caused by my >> toolchain? >> >> I am waiting for your reply, Thank you! >> >> >> [1]. http://gcc.gnu.org/ml/gcc/2012-12/msg00079.html >> [2]. http://www.phoronix.com/scan.php?page=news_item&px=MTI1MDU > > > No it's not true, you've misunderstood. > > There was a proposal to deprecate (not remove) i386 support, but it > didn't happen. > > Even if it did happen, that wouldn't remove support for lock-free > atomic ints, only i386 targets would be affected (not i486 or later), > and they don't fully support lock-free atomic ints anyway.
Re: i386 __atomic_compare_exchange_n not found
Hi all, does anyone know how to configure gcc to build with "__atomic_compare_exchange_n" support for i386 target? WeiY Best Regards 在 2013-8-6,下午11:37,Jonathan Wakely 写道: > On 6 August 2013 16:30, Deng Hengyi wrote: >> Hi Jonathan, >> >> Thank you for your reply. >> And about the error i encounter, do you have any advice? maybe it is caused >> by my toolchain not install rightly? >> In the standard pc686 architecture(not cross compile on RTEMS) will it >> encounter the similar error? > > I don't know anything about the RTEMS port. You might need to build > and link to libatomic, but I don't know.
Re: i386 __atomic_compare_exchange_n not found
Hi Joel, I have done a test, it seems that '-march=i386' does not provide "__atomic_compare_exchange_n" libs. And '-march=i486' or '-march=pentium' can find the '__atomic_compare_exchange_n' function. weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -march=i386 -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 /tmp/ccTmf1pa.o: In function `main': test.c:(.text+0xaa): undefined reference to `__atomic_compare_exchange_4' test.c:(.text+0xfa): undefined reference to `__atomic_compare_exchange_4' collect2: error: ld returned 1 exit status weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -march=i486 -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -march=i686 -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -march=i586 -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -march=pentium -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 weiy@ubuntu:~/project/gsoc/gsoc2013/rtems-build/arm-build$ i386-rtems4.11-gcc -m32 -o test test.c /home/weiy/project/gsoc/gsoc2013/rtems-toolchain/4.11/lib/gcc/i386-rtems4.11/4.8.1/../../../../i386-rtems4.11/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048074 /tmp/cctQ68SN.o: In function `main': test.c:(.text+0xaa): undefined reference to `__atomic_compare_exchange_4' test.c:(.text+0xfa): undefined reference to `__atomic_compare_exchange_4' collect2: error: ld returned 1 exit status WeiY Best Regards 在 2013-8-10,上午12:02,Joel Sherrill 写道: > On 8/9/2013 10:15 AM, Deng Hengyi wrote: >> Hi all, >> >> does anyone know how to configure gcc to build with >> "__atomic_compare_exchange_n" support for i386 target? > > I recall that one issue with *-rtems* targets is that > we support CPU models which are lower than typically > used on Linux and BSD systems. I recall that CPU > models like the mc68000 and i386 don't necessarily > have the atomic instructions available in later models > like the mc68040 or i686. > > My suggestion is to see specifically how that is > implemented on the other CPU models and which models > don't have implementations. Then we can figure out > how to implement it. > > For lower model CPUs, it should be safe to assume they > will never be seen in SMP systems and using a > generic RTEMS providing implementation that disables > interrupts and does the operation is OK. > > --joel >> WeiY >> Best Regards >> 在 2013-8-6,下午11:37,Jonathan Wakely 写道: >> >>> On 6 August 2013 16:30, Deng Hengyi wrote: >>>> Hi Jonathan, >>>> >>>> Thank you for your reply. >>>> And about the error i encounter, do you have any advice? maybe it is >>>> caused by my toolchain not install rightly? >>>> In the standard pc686 architecture(not cross compile on RTEMS) will it >>>> encounter the similar error? >>> I don't know anything about the RTEMS port. You might need to build >>> and link to libatomic, but I don't know. > > > -- > Joel Sherrill, Ph.D. Director of Research & Development > joel.sherr...@oarcorp.comOn-Line Applications Research > Ask me about RTEMS: a free RTOS Huntsville AL 35805 > Support Available(256) 722-9985 >