Re: [Boost-users] [Thread] Not able to compile a program with Thread library on ARM
Dear all,
I've got the following problem: I want to use the boost threading library provided in version 1.36 on an arm (imx31) based evaluation board with MontaVista linux and g++ version 4.2.0 on it. When I try to compile the following example with my arm-g++ compiler
I ran into this same problem on ARM. Sounds like you've found the fix, but FYI: I just made Boost short-circuit the tests for GCC-specific atomic code on ARM, and use the generic pthreads versions instead. See the attached patch.
Hi Matthew, I compiled boost thread with your patch but I got lots of compilation errors. Maybe I haven't set-up my boost environment correctly. So could you please give me some further details / advices on your compilation setting (flags, etc.) and how I have to compile the thread library. I've added a patch which includes two specialized implementations of 'atomic_count' and 'sp_counted_base' for ARMv6 and higher which are used by shared_ptr. In my mind, this could be an optimal implementation for these architectures as I used LDREX and STREX instructions within each atomic operation. This means, that I load (using LDREX) a particular value from memory, operate on it, e.g.: increment the value, and write it back to the memory with STREX. During this computation the system assumes that no one else writes to this address. This is a very optimistic approach and does not block the external bus of the processor. Thus, others could continue with their computations which could possibly lead to a performance gain. STREX indicates whether someone has changed the value of this address during our atomic operation. If so, we have to jump back to the beginning of the operation and start the operation again. Note: I tried to implement the __sync_add...() functions which are used in the ...sync.hpp files. For a detailed description of these functions, please refer to http://www.mcs.vuw.ac.nz/cgi-bin/info2www?(gcc)Atomic+Builtins Best regards, Rudi Dittrich
-- Matthew L. Creech
On Fri, Sep 26, 2008 at 4:18 AM, Rudi Dittrich
Hi Matthew,
I compiled boost thread with your patch but I got lots of compilation errors. Maybe I haven't set-up my boost environment correctly. So could you please give me some further details / advices on your compilation setting (flags, etc.) and how I have to compile the thread library.
Hi Rudi. I've no idea about the ARM-specific patches, I just did the minimal amount necessary to get Boost to build for an ARM-Linux target. What errors do you get when you try to build with the patch I sent earlier? For comparison, I'm using a custom built toolchain (gcc-4.3.2, eglibc-2.8, binutils 2.18), and I didn't do anything too special to build Boost (other than the hacks needed to do any cross-compilation at all). From my Makefile: cd boost_$(BOOST_VERSION) && \ ./configure --prefix="$(PREFIX)" --with-libraries=$(WITH_LIBS) && \ VER="`$(CC) -dumpversion`" && \ echo "using gcc : $$VER : $(CC) ;" > user-config.jam then just "make install" to build & install. I also tried your test program from the original email, and it builds fine for me (I don't have a target to try running it on right now). In addition to the one patch I sent before, there were 2 others (both extremely minor) that I needed to prevent build issues with the library or with client code. I'll attach all 3 in case that helps at all. -- Matthew L. Creech
participants (2)
-
Matthew L. Creech
-
Rudi Dittrich