McGregor80
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am

Performance difference on PI2

Tue Feb 10, 2015 5:58 pm

Hi,
I made an application compiled on gcc 4.7. It was made for raspbian 2013.09 (somewhere around this date) installed on RPi B.
The application uses I2C, UART, some GPIO.

Today i tried to run it on The RPi2 (latest raspbian 2015.01.31). I made some small changes related to DT(device tree) and gpio address area to simply run all the interfaces and.

It works, but... it seems to be slower on PI2 than on PI1. As i have both versions i rebooted them at the same time and this what took PI1 5 minutes takes PI2 at least 12 minutes.

What can it be?
New kernel? More background tasks ? (raspbian 2015 takes twice as much hd space comparing with Raspbian 2013)
Or maybe i should compile with native raspberry gcc to squeeze more from the HW?
Is there any other gcc compilator version which supports the 4 cores SoC?

Interesting is that when i look att "sudo top" i see it takes much less processor power on Pi2 than Pi1

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26459
Joined: Sat Jul 30, 2011 7:41 pm

Re: Performance difference on PI2

Tue Feb 10, 2015 6:46 pm

If CPU usage is less, then it is waiting for stuff to happen, rather than being slow.

Since you are using HW, I'd think time-outs going odd somewhere, or perhaps the higher speed of the cores is missing something that it previously caught.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5592
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Performance difference on PI2

Thu Feb 12, 2015 9:38 am

Are you using the same kernel on both Pi's? (ie. has Raspbian on the B been updated etc.)
Are you "exporting" GPIO pins - if so this thread may be relevant:
http://www.raspberrypi.org/forums/viewt ... 44&t=99113
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Performance difference on PI2

Thu Feb 12, 2015 10:51 am

Could it be related to this:
http://www.raspberrypi.org/forums/viewt ... 25#p684326
identified as:
http://www.raspberrypi.org/forums/viewt ... 50#p684457
?

(I think I saw some commit from Phil_E which addressed this, but could not find link right now)

I'm having issues with RTLSDR-Airband - the textual waterfall display runs at least half speed on the 2B vs B+, and it sounds like Norman Collier is piloting the planes. So far I've identified it's not the gpu_fft code, so next to investigate the sample collection from the usb sdr dongle.

McGregor80
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am

Re: Performance difference on PI2

Sat Feb 21, 2015 7:57 pm

FTrevorGowen wrote:Are you using the same kernel on both Pi's? (ie. has Raspbian on the B been updated etc.)
Are you "exporting" GPIO pins - if so this thread may be relevant:
http://www.raspberrypi.org/forums/viewt ... 44&t=99113
Trev.
Thanks but i guess it is not the issue on my application.
I wrote it in c and i map memory for the pin access.

I noticed however that the i2c display i have tends to be really slow. I don't know why.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Performance difference on PI2

Sat Feb 21, 2015 8:00 pm

What does "vcgencmd version" report?
I suspect it is the issue @gregeric linked to, which has been fixed in newer firmware.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Performance difference on PI2

Thu Feb 26, 2015 10:47 pm

gregeric wrote:I'm having issues with RTLSDR-Airband - the textual waterfall display runs at least half speed on the 2B vs B+, and it sounds like Norman Collier is piloting the planes. So far I've identified it's not the gpu_fft code, so next to investigate the sample collection from the usb sdr dongle.
In this case, I've pinpointed the slow-down to some vfp optimised assembly which runs like treacle on the Pi2.

Reverting to the author's c routine from the commit before the assembly was substituted has got things working.

enedil
Posts: 66
Joined: Sat Feb 21, 2015 4:22 pm
Location: Toruń, Poland
Contact: Website

Re: Performance difference on PI2

Thu Feb 26, 2015 11:16 pm

Does the issue still exist if you compile your app using LLVM/clang (avaliable in repositories)?
- What Can a Thoughtful Man Hope for Mankind on Earth, Given the Experience of the Past Million Years?
- Nothing.

Kurt Vonnegut, Cat's Cradle

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Performance difference on PI2

Mon Mar 02, 2015 2:13 pm

Hi - thanks for the suggestion. With llvm-g++ it errors out:

Code: Select all

as -o rtl_airband_asm.o rtl_airband_asm.s -mcpu=arm1176jzf-s -march=armv6zk -mfpu=vfp
llvm-g++ -L/opt/vc/lib/ -lbcm_host -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -lrt -lm -lvorbisenc -lmp3lame -lshout -lpthread -lrtlsdr -o rtl_airband -O3 -mtune=arm1176jzf-s -mcpu=arm1176jzf-s -march=armv6zk -mfpu=vfp  rtl_airband.cpp hello_fft/mailbox.c hello_fft/gpu_fft.c hello_fft/gpu_fft_base.c hello_fft/gpu_fft_twiddles.c hello_fft/gpu_fft_shaders.c rtl_airband_asm.s
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
Potential incompatible plugin version. GCC: 4.6 (20120301). Expected: 4.6 (20121127)
Defines 'dragonegg_disable_version_check' as env variable to remove this warning
Please note that unexpected errors might occur.
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/cctp8Ghw.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/cctp8Ghw.o
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/ccShZDMc.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccShZDMc.o
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/ccdcmMvd.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccdcmMvd.o
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/ccnHITRT.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccnHITRT.o
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/ccS7q7h0.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccS7q7h0.o
/usr/bin/ld: error: rtl_airband uses VFP register arguments, /tmp/ccW0eft0.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccW0eft0.o
collect2: ld returned 1 exit status
makefile:28: recipe for target 'rtl_airband' failed
make: *** [rtl_airband] Error 1
Are those errors meaningful to you?

enedil
Posts: 66
Joined: Sat Feb 21, 2015 4:22 pm
Location: Toruń, Poland
Contact: Website

Re: Performance difference on PI2

Tue Mar 03, 2015 6:37 pm

I don't know what are you using, but you should install package clang and run compiler

Code: Select all

clang++ file.cpp -o file
- What Can a Thoughtful Man Hope for Mankind on Earth, Given the Experience of the Past Million Years?
- Nothing.

Kurt Vonnegut, Cat's Cradle

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26459
Joined: Sat Jul 30, 2011 7:41 pm

Re: Performance difference on PI2

Tue Mar 03, 2015 7:00 pm

gregeric wrote:
gregeric wrote:I'm having issues with RTLSDR-Airband - the textual waterfall display runs at least half speed on the 2B vs B+, and it sounds like Norman Collier is piloting the planes. So far I've identified it's not the gpu_fft code, so next to investigate the sample collection from the usb sdr dongle.
In this case, I've pinpointed the slow-down to some vfp optimised assembly which runs like treacle on the Pi2.

Reverting to the author's c routine from the commit before the assembly was substituted has got things working.
That's interesting. Can you flag up which function is causing the problems on the Pi2, that clearly needs to be checked.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Performance difference on PI2

Wed Mar 04, 2015 12:51 pm

Hi James - it's the samplefft() assembly routine which applies a window function prior to calling gpu_fft(). Here's my fork:

https://github.com/campag/RTLSDR-Airban ... band_asm.s

In the makefile there are configurations to build for arm6 or arm7. The arm6 build runs fine on the older models.

To get it to work on the Pi2B, I inserted a define so as to swap out the asm for samplefft(), instead using original author microtony's deprecated c code to apply the window function. The other asm routine, fftwave(), which does the am demodulation, is retained & works.

You will need an rtl2832 dongle to test the code as-is, or create a new test program which calls the asm.

Edit: Could it be the .align 2? I'll try .align 4 later.
Edit2: Nope, that didn't fix (or break) it.
Last edited by gregeric on Thu Mar 05, 2015 7:58 am, edited 3 times in total.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Performance difference on PI2

Wed Mar 04, 2015 12:54 pm

enedil wrote:I don't know what are you using, but you should install package clang and run compiler

Code: Select all

clang++ file.cpp -o file
I installed clang now, was using llvm before. There were some warnings on compiling in both the asm parts and c parts of the source (sorry, no access to it right now). Will post later. Resultant binary perfoms similarly: OK on Pi1, NOK on Pi2

Edit: Here's the compiler output when trying to build for Pi1, runs badly on Pi2:

Code: Select all

clang++ -L/opt/vc/lib/ -lbcm_host -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -lrt -lm -lvorbisenc -lmp3lame -lshout -lpthread -lrtlsdr -o rtl_airband -O3 -mtune=arm1176jzf-s -mcpu=arm1176jzf-s -march=armv6zk -mfpu=vfp  rtl_airband.cpp hello_fft/mailbox.c hello_fft/gpu_fft.c hello_fft/gpu_fft_base.c hello_fft/gpu_fft_twiddles.c hello_fft/gpu_fft_shaders.c rtl_airband_asm.s
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
rtl_airband.cpp:344:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
rtl_airband.cpp:663:50: warning: '&&' within '||' [-Wlogical-op-parentheses]
                        if (channel->agcsq == -1 && channel->agcavgslow < 2.4f * channel->agcmin || channel->agclow == AGC_EXTRA - 12) {
                            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
rtl_airband.cpp:663:50: note: place parentheses around the '&&' expression to silence this warning
                        if (channel->agcsq == -1 && channel->agcavgslow < 2.4f * channel->agcmin || channel->agclow == AGC_EXTRA - 12) {
                                                 ^
                            (                                                                   )
2 warnings generated.
/tmp/gpu_fft-wZYH7n.s: Assembler messages:
/tmp/gpu_fft-wZYH7n.s:75: Rd and Rm should be different in mul
/tmp/gpu_fft-wZYH7n.s:125: Rd and Rm should be different in mla
/tmp/gpu_fft-wZYH7n.s:240: Rd and Rm should be different in mla

Return to “C/C++”