[SOLVED] Building TBB on Linux/PPC architecture

[SOLVED] Building TBB on Linux/PPC architecture

Bild des Benutzers wakko

Hi.
I am trying to build TBB on a Linux machine running on a P4080 PowerPC architecture.
The makefile successfully auto-detects the architecture but fails to build due to the
disabled "part-word CAS" implementation.
I have thoroughly searched the forum but couldn't find any related issues.

muse tbb40_20120408oss # make arch=ppc

Created ./build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_release and ..._debug directories

make -C "./build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_debug"  -r -f ../../build/Makefile.tbb cfg=debug tbb_root=../..

make[1]: Entering directory `/home/muse/tbb40_20120408oss/build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_debug'

../../build/Makefile.tbb:39: CONFIG: cfg=debug arch=ppc compiler=gcc os=linux runtime=cc4.4.5_libc2.11.3_kernel3.0.25

g++ -c -MMD -DTBB_USE_DEBUG -DDO_ITT_NOTIFY -g -O0 -DUSE_PTHREAD -fPIC -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-non-virtual-dtor    -I../../src -I../../src/rml/include -I../../include ../../src/tbb/concurrent_hash_map.cpp

In file included from ../../include/tbb/spin_rw_mutex.h:33,

                 from ../../include/tbb/concurrent_hash_map.h:50,

                 from ../../src/tbb/concurrent_hash_map.cpp:29:

../../include/tbb/tbb_machine.h:378:10: error: #error generic implementation of part-word CAS was explicitly disabled for this configuration

make[1]: *** [concurrent_hash_map.o] Error 1
It seems to be related to the "endian-ness", however I have no idea how to fix this.
Do you have any hints on how to proceed with this?

8 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Raf Schietekat

Strange... why did you specify arch at all, and with an unsupported value? Try omitting it, or use ppc32 or ppc64 (only) if you want to override automatic detection (typically if you want to build 32-bit software on 64-bit hardware).

You've also run into a new bug, though: invert the test for __TBB_BIG_ENDIAN to check for equality instead of inequality to -1 (the current generic implementation wouldn't know how to deal with mixed-endian architectures or ones where endianness is determined based on locaton, as purportedly for certain embedded PowerPC implementations, but it should work with __TBB_BIG_ENDIAN being 0 or 1).

I'll try to remember to take the new release for a spin (no pun intended) on PowerPC, myself, but this should get you going already.

Bild des Benutzers wakko

Thanks for your reply. The arch=ppc parameter slipped into the pasted output accidentally.
Of course I had also tried to rely on the automatic platform detection which gave the same
result, though.
Inverting the test for __TBB_BIG_ENDIAN seems to skip the definition of the templated function
"__TBB_MaskedCompareAndSwap", which results in this error:

muse1 tbb40_20120613oss # make

Created ./build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_release and ..._debug directories

make -C "./build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_debug"  -r -f ../../build/Makefile.tbb cfg=debug tbb_root=../..

make[1]: Entering directory `/home/muse/tbb40_20120613oss/build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_debug'

../../build/Makefile.tbb:39: CONFIG: cfg=debug arch=ppc compiler=gcc os=linux runtime=cc4.4.5_libc2.11.3_kernel3.0.25

g++ -c -MMD -DTBB_USE_DEBUG -DDO_ITT_NOTIFY -g -O0 -DUSE_PTHREAD -fPIC -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-non-virtual-dtor    -I../../src -I../../src/rml/include -I../../include ../../src/tbb/concurrent_hash_map.cpp

In file included from ../../include/tbb/spin_rw_mutex.h:33,

                 from ../../include/tbb/concurrent_hash_map.h:50,

                 from ../../src/tbb/concurrent_hash_map.cpp:29:

../../include/tbb/tbb_machine.h: In function 'T tbb::internal::__TBB_CompareAndSwapGeneric(volatile void*, T, T) [with unsigned int S = 1u, T = unsigned char]':

../../include/tbb/tbb_machine.h:429: error: '__TBB_MaskedCompareAndSwap' was not declared in this scope

../../include/tbb/tbb_machine.h:429: error: expected primary-expression before '>' token

../../include/tbb/tbb_machine.h:429: warning: left-hand operand of comma has no effect

../../include/tbb/tbb_machine.h:429: warning: right-hand operand of comma has no effect

../../include/tbb/tbb_machine.h: In function 'T tbb::internal::__TBB_CompareAndSwapGeneric(volatile void*, T, T) [with unsigned int S = 2u, T = short unsigned int]':

../../include/tbb/tbb_machine.h:438: error: '__TBB_MaskedCompareAndSwap' was not declared in this scope

../../include/tbb/tbb_machine.h:438: error: expected primary-expression before '>' token

../../include/tbb/tbb_machine.h:438: warning: left-hand operand of comma has no effect

../../include/tbb/tbb_machine.h:438: warning: right-hand operand of comma has no effect

make[1]: *** [concurrent_hash_map.o] Error 1

make[1]: Leaving directory `/home/muse/tbb40_20120613oss/build/linux_ppc_gcc_cc4.4.5_libc2.11.3_kernel3.0.25_debug'

As "__TBB_USE_GENERIC_PART_WORD_CAS" is still enabled it cannot find the now undefined function
"__TBB_MaskedCompareAndSwap" that is used in line 429 and 438 (I have meanwhile updated to tbb40_20120613oss).
Just to clarify: Only this single line(381) has been changed:
// #if (__TBB_BIG_ENDIAN!=-1)

// changed to

#if (__TBB_BIG_ENDIAN==-1) // returns false on my machine and skips the following declaration...

Bild des Benutzers Raf Schietekat

Sorry, my advice was incomplete.

You should exchange the conditions as well as inverting the test for __TBB_BIG_ENDIAN:

#if ( __TBB_USE_GENERIC_PART_WORD_CAS)
#if (__TBB_BIG_ENDIAN==-1)
#error generic implementation of part-word CAS was explicitly disabled for this configuration
#endif

Note that the test for __TBB_BIG_ENDIAN is also implied by the tests in endianness::is_big_endian(), except that there it doesn't have its very own #error message. I guess it's a matter of preference whether to include the test there as a special case or to have it before the function.

(Edited.)

Bild des Benutzers wakko

Thanks again. It's almost compiling now, but now it is tripping over two unrecognized assembly
instructions "lock" and "xaddl" which are used in "$tbb_dir/src/tbb/tools_api/ittnotify_config.h" (line 265, function int __TBB_machine_fetchadd4).
I am afraid that these instructions are in fact missing on my hardware and I am investigating how to
replace the missing opcodes with existing ones. The __TBB_machine_fetchadd4 function looks similar to
an atomic add or atomic incerement (http://www.memoryhole.net/kyle/2007/05/atomic_incrementing.html).
I am trying to figure it out myself, however any help will be appreciated.

Bild des Benutzers Raf Schietekat

ittnotify_config.h only has 105 lines of code, and those instructions are not for PowerPC at all. I suspect that this is about __TBB_machine_fetchadd4() in ittnotify_static.c:175, which should be corrected by the TBB team.

As a workaround, try to disable ITT support (you don't have those tools anyway) with the following modification at build/linux.gcc.inc:56: ITT_NOTIFY = -DDO_ITT_NOTIFY=0.

Bild des Benutzers wakko

Thanks for all your suggestions.
It seems to be working now and I finally have a successful PPC build.

Bild des Benutzers Raf Schietekat

I suggest running the full test suite for a while (give it a few hours maybe), to see if any data races manifest themselves in some way. The code should be quite solid now, but it was not originally written for such a weak processor (in the technical memory-semantics sense), and you never know that problems haven't have crept in again.

Melden Sie sich an, um einen Kommentar zu hinterlassen.