computation speed in Neutrino

I am converting a control program of a robot arm from QNX4 to Neutrino
(6.2). What puzzled me is that the same codes will take longer time for
computation in Neutrino than QNX4, and this adversely affects the stability
of the robot arm (previous stable system becomes unstable now). The code
basically deals with reading encoders, calculating the compensation outputs,
and output to D/A card. A hardware interrupt is used to generate a 100Hz
sampling rate. The hardware configurations are the same.



I also tried a much simpler process like just writing to the registers of
the D/A card, and it takes LONGER time for the card to react in Neutrino
than in QNX 4. Could any guru please let me know which may cause the
difference? And how to solve the problem, if possible?



Here are some information related to the computer system (any other
information are needed, please let me know):



CPU: 586 Cyrix, 299MHz, FPU; 127M memory available.



Compiler: QCC for Neutrino, Watcom for QNX4.



Priority of the Process: 10 (I increased the priority of the process, but
have no improvement)



Other processes running (blocked) concurrently:

/boot/sys/procnto

sbin/tinit

proc/boot/sloggger

sbin/mqueue

proc/boot/pci-bios

roc/boot/devb-eide

/x86/sbin/devc-con

.4/x86/sbin/fs-pkg

sbin/pipe

sbin/devp-pccard

sbin/devc-pty

sbin/devc-par

sbin/io-net

usr/sbin/spooler

sbin/devc-ser8250

sbin/devb-fdc

usr/sbin/inetd

usr/sbin/random

usr/sbin/dumper

usr/sbin/dhcp.client

usr/photon/bin/pterm

usr/photon/bin/pwm

/photon/bin/photon

photon/bin/fontsleuth

bin/sh

photon/bin/io-graphics

photon/bin/devi-hirun

usr/photon/bin/shelf

photon/bin/bkgdmgr

photon/bin/wmswitch

usr/phton/bin/saver



Thanks a lot,

Jeff

Make sure that you’re reading/writing registers in appropriate way for the
hardware. For example, if the hardware has 16bit regs, but you access via a
32 bit read, you could be generating 2 bus cycles unnecessarily. You may
want to take a look via a bus analyzer to see what kind of activity is going
on.

The other is to take a look at the optimization level of the compiler, while
this will have no effect on the speed of register writing, other places
might be slower if the code gen is less optimal than what the Watcom
compiler made in QNX4.

-Adam

Jeff Chang <jianjunc@cae.wisc.edu> wrote in message
news:bbqfm0$7q9$1@inn.qnx.com

I am converting a control program of a robot arm from QNX4 to Neutrino
(6.2). What puzzled me is that the same codes will take longer time for
computation in Neutrino than QNX4, and this adversely affects the
stability
of the robot arm (previous stable system becomes unstable now). The code
basically deals with reading encoders, calculating the compensation
outputs,
and output to D/A card. A hardware interrupt is used to generate a 100Hz
sampling rate. The hardware configurations are the same.



I also tried a much simpler process like just writing to the registers of
the D/A card, and it takes LONGER time for the card to react in Neutrino
than in QNX 4. Could any guru please let me know which may cause the
difference? And how to solve the problem, if possible?



Here are some information related to the computer system (any other
information are needed, please let me know):



CPU: 586 Cyrix, 299MHz, FPU; 127M memory available.



Compiler: QCC for Neutrino, Watcom for QNX4.



Priority of the Process: 10 (I increased the priority of the process, but
have no improvement)



Other processes running (blocked) concurrently:

/boot/sys/procnto

sbin/tinit

proc/boot/sloggger

sbin/mqueue

proc/boot/pci-bios

roc/boot/devb-eide

/x86/sbin/devc-con

.4/x86/sbin/fs-pkg

sbin/pipe

sbin/devp-pccard

sbin/devc-pty

sbin/devc-par

sbin/io-net

usr/sbin/spooler

sbin/devc-ser8250

sbin/devb-fdc

usr/sbin/inetd

usr/sbin/random

usr/sbin/dumper

usr/sbin/dhcp.client

usr/photon/bin/pterm

usr/photon/bin/pwm

/photon/bin/photon

photon/bin/fontsleuth

bin/sh

photon/bin/io-graphics

photon/bin/devi-hirun

usr/photon/bin/shelf

photon/bin/bkgdmgr

photon/bin/wmswitch

usr/phton/bin/saver



Thanks a lot,

Jeff

Thanks a lot for your comments. I am not a computer guy, could you please
give me some more details regarding how to modify the optimization level of
the compiler in QNX, if possible?

Thank you very much,
Jeff
“Adam Mallory” <amallory@qnx.com> wrote in message
news:bbqmfo$94o$1@nntp.qnx.com

Make sure that you’re reading/writing registers in appropriate way for the
hardware. For example, if the hardware has 16bit regs, but you access via
a
32 bit read, you could be generating 2 bus cycles unnecessarily. You may
want to take a look via a bus analyzer to see what kind of activity is
going
on.

The other is to take a look at the optimization level of the compiler,
while
this will have no effect on the speed of register writing, other places
might be slower if the code gen is less optimal than what the Watcom
compiler made in QNX4.

-Adam

Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bbqfm0$7q9$> 1@inn.qnx.com> …
I am converting a control program of a robot arm from QNX4 to Neutrino
(6.2). What puzzled me is that the same codes will take longer time for
computation in Neutrino than QNX4, and this adversely affects the
stability
of the robot arm (previous stable system becomes unstable now). The code
basically deals with reading encoders, calculating the compensation
outputs,
and output to D/A card. A hardware interrupt is used to generate a 100Hz
sampling rate. The hardware configurations are the same.



I also tried a much simpler process like just writing to the registers
of
the D/A card, and it takes LONGER time for the card to react in
Neutrino
than in QNX 4. Could any guru please let me know which may cause the
difference? And how to solve the problem, if possible?



Here are some information related to the computer system (any other
information are needed, please let me know):



CPU: 586 Cyrix, 299MHz, FPU; 127M memory available.



Compiler: QCC for Neutrino, Watcom for QNX4.



Priority of the Process: 10 (I increased the priority of the process,
but
have no improvement)



Other processes running (blocked) concurrently:

/boot/sys/procnto

sbin/tinit

proc/boot/sloggger

sbin/mqueue

proc/boot/pci-bios

roc/boot/devb-eide

/x86/sbin/devc-con

.4/x86/sbin/fs-pkg

sbin/pipe

sbin/devp-pccard

sbin/devc-pty

sbin/devc-par

sbin/io-net

usr/sbin/spooler

sbin/devc-ser8250

sbin/devb-fdc

usr/sbin/inetd

usr/sbin/random

usr/sbin/dumper

usr/sbin/dhcp.client

usr/photon/bin/pterm

usr/photon/bin/pwm

/photon/bin/photon

photon/bin/fontsleuth

bin/sh

photon/bin/io-graphics

photon/bin/devi-hirun

usr/photon/bin/shelf

photon/bin/bkgdmgr

photon/bin/wmswitch

usr/phton/bin/saver



Thanks a lot,

Jeff
\

Jeff Chang <jianjunc@cae.wisc.edu> wrote in message
news:bc17tb$okh$1@inn.qnx.com

Thanks a lot for your comments. I am not a computer guy, could you please
give me some more details regarding how to modify the optimization level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being low, 3
being high), but as I mentioned, it won’t have much affect in terms of
register read/write.

-Adam

Thanks.
And, is it possible to use Watcom compiler in neutrino?
Jeff

“Adam Mallory” <amallory@qnx.com> wrote in message
news:bc1uhs$o2a$1@nntp.qnx.com

Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bc17tb$okh$> 1@inn.qnx.com> …
Thanks a lot for your comments. I am not a computer guy, could you
please
give me some more details regarding how to modify the optimization level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being low, 3
being high), but as I mentioned, it won’t have much affect in terms of
register read/write.

-Adam

Yes, Watcom support would be very nice indeed!

Murf

Jeff Chang wrote:

Thanks.
And, is it possible to use Watcom compiler in neutrino?
Jeff

“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:bc1uhs$o2a$> 1@nntp.qnx.com> …
Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bc17tb$okh$> 1@inn.qnx.com> …
Thanks a lot for your comments. I am not a computer guy, could you
please
give me some more details regarding how to modify the optimization level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being low, 3
being high), but as I mentioned, it won’t have much affect in terms of
register read/write.

-Adam

So, do you mean that Neutrino already includes the Watcom compiler? or
should I import the Watcom compiler?

Basically, could you please tell me how to compile C/C++ code using Watcom
compiler in Neutrino? As I checked the utility reference, it’s said that
“Under QNX 4, CC and cc are links to an older compiler that you can’t use to
compile code for QNX 6.” Is that watcom only used for QNX4?

Thanks a lot,
Jeff

“John A. Murphy” <murf@perftech.com> wrote in message
news:3EE6457E.9A51662C@perftech.com

Yes, Watcom support would be very nice indeed!

Murf

Jeff Chang wrote:

Thanks.
And, is it possible to use Watcom compiler in neutrino?
Jeff

“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:bc1uhs$o2a$> 1@nntp.qnx.com> …
Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bc17tb$okh$> 1@inn.qnx.com> …
Thanks a lot for your comments. I am not a computer guy, could you
please
give me some more details regarding how to modify the optimization
level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being
low, 3
being high), but as I mentioned, it won’t have much affect in terms of
register read/write.

-Adam

Watcom is only officially available/supported for QNX4.

With the release of the Watcom compiler to open source (see
www.openwatcom.com) it should, in theory, be possible to port it to QNX6. I
haven’t looked into it in any detail but from my brief scanning of the
OpenWatcom site this would not be particularly easy, although I see a Linux
port has now been done so that would be a good starting point. Anybody
already working on it? Any volunteers?

Personally we have just about finished porting all our code to STL/GCC and
so it is no longer much of an issue.

While I like the Watcom compiler it is a long way from complying with the
C++ standard. But on-topic to this thread, it wouldn’t surprise me at all if
in some circumstances the Watcom compiler produced better optimised x86 code
than GCC.

Rob Rutherford

“Jeff Chang” <jianjunc@cae.wisc.edu> wrote in message
news:bc5ga3$ltk$1@inn.qnx.com

So, do you mean that Neutrino already includes the Watcom compiler? or
should I import the Watcom compiler?

Basically, could you please tell me how to compile C/C++ code using Watcom
compiler in Neutrino? As I checked the utility reference, it’s said that
“Under QNX 4, CC and cc are links to an older compiler that you can’t use
to
compile code for QNX 6.” Is that watcom only used for QNX4?

Thanks a lot,
Jeff

“John A. Murphy” <> murf@perftech.com> > wrote in message
news:> 3EE6457E.9A51662C@perftech.com> …
Yes, Watcom support would be very nice indeed!

Murf

Jeff Chang wrote:

Thanks.
And, is it possible to use Watcom compiler in neutrino?
Jeff

“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:bc1uhs$o2a$> 1@nntp.qnx.com> …
Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bc17tb$okh$> 1@inn.qnx.com> …
Thanks a lot for your comments. I am not a computer guy, could you
please
give me some more details regarding how to modify the optimization
level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being
low, 3
being high), but as I mentioned, it won’t have much affect in terms
of
register read/write.

-Adam
\

Do you think the hardware I am using consists of a problem too?

As I also find that the system is slow while I scroll down the windows. I am
using a PC/104+ cpumodule with 300MHz and 128M RAM. Should QNX 6 be
installed in a system with 650MHz cpu and 258M RAM?

Thanks for all your inputs,
Jeff

“Robert Rutherford” <ruzz@NoSpamPlease.ruzz.com> wrote in message
news:bc5p6f$26p$1@inn.qnx.com

Watcom is only officially available/supported for QNX4.

With the release of the Watcom compiler to open source (see
www.openwatcom.com> ) it should, in theory, be possible to port it to QNX6.
I
haven’t looked into it in any detail but from my brief scanning of the
OpenWatcom site this would not be particularly easy, although I see a
Linux
port has now been done so that would be a good starting point. Anybody
already working on it? Any volunteers?

Personally we have just about finished porting all our code to STL/GCC and
so it is no longer much of an issue.

While I like the Watcom compiler it is a long way from complying with the
C++ standard. But on-topic to this thread, it wouldn’t surprise me at all
if
in some circumstances the Watcom compiler produced better optimised x86
code
than GCC.

Rob Rutherford

“Jeff Chang” <> jianjunc@cae.wisc.edu> > wrote in message
news:bc5ga3$ltk$> 1@inn.qnx.com> …
So, do you mean that Neutrino already includes the Watcom compiler? or
should I import the Watcom compiler?

Basically, could you please tell me how to compile C/C++ code using
Watcom
compiler in Neutrino? As I checked the utility reference, it’s said that
“Under QNX 4, CC and cc are links to an older compiler that you can’t
use
to
compile code for QNX 6.” Is that watcom only used for QNX4?

Thanks a lot,
Jeff

“John A. Murphy” <> murf@perftech.com> > wrote in message
news:> 3EE6457E.9A51662C@perftech.com> …
Yes, Watcom support would be very nice indeed!

Murf

Jeff Chang wrote:

Thanks.
And, is it possible to use Watcom compiler in neutrino?
Jeff

“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:bc1uhs$o2a$> 1@nntp.qnx.com> …
Jeff Chang <> jianjunc@cae.wisc.edu> > wrote in message
news:bc17tb$okh$> 1@inn.qnx.com> …
Thanks a lot for your comments. I am not a computer guy, could
you
please
give me some more details regarding how to modify the
optimization
level
of
the compiler in QNX, if possible?

using qcc, check out the -O option for optimization level (0 being
low, 3
being high), but as I mentioned, it won’t have much affect in
terms
of
register read/write.

-Adam


\

Jeff Chang <jianjunc@cae.wisc.edu> wrote:

Do you think the hardware I am using consists of a problem too?

As I also find that the system is slow while I scroll down the windows. I am
using a PC/104+ cpumodule with 300MHz and 128M RAM. Should QNX 6 be
installed in a system with 650MHz cpu and 258M RAM?

More likly that you need to investigate using a better supported video card
or a better driver. What video driver are you using?

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

The video chip I used is Chips and Technologies 65545 VGA controller, which
is supported by QNX4.25 but not by QNX6.2.1. Since my application is an
embedded system, the video card is used now only for debugging, and will not
be used later in the field, so is the photon.

I used -O3 option to increased the optimization level, but no big
improvments.

I think I need to describe my program more clearly as I observed something
weird while I was trying to measure the computation time of my control loop.
Here is the control loop structure:

… // codes setting up hardware, triggering a hardware interrupt at
100Hz, which will send a pulse back to the process
// create channel, and attach connect to the process itself.
While(1)
{
SenderPID = MsgReceive(Channel_id, &msg, sizeof(msg), NULL);

if(SenderPID == 0)
// receive the pulse, in this case it’s just from the interrupt
{
start = clock(); // record the start time;

… // all the control algorithms, and
computations


finish = clock();

duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf("%12.6f seconds,\n",duration);

}

}

I found that the printed-out ‘duration’ value is not a constant, it may be
equal to a big value, like0.004s; and may be equal to a small value, like
0.0006s. I don’t know what caused this variation in computing the same piece
of code.

The other weired thing I observed is that, I increased the priority of the
process to 13 in the very beginning, higher than some of the photon
services. Then, while the process is running, I typed “pidin” in another
terminal to check the status of the process, and it simply displayed the
priority as “10r”. Could anybody also explain this to me a little bit?

Thanks a lot for all your inputs,
Jeff

“Chris McKillop” <cdm@qnx.com> wrote in message
news:bc6gbm$97l$1@nntp.qnx.com

Jeff Chang <> jianjunc@cae.wisc.edu> > wrote:
Do you think the hardware I am using consists of a problem too?

As I also find that the system is slow while I scroll down the windows.
I am
using a PC/104+ cpumodule with 300MHz and 128M RAM. Should QNX 6 be
installed in a system with 650MHz cpu and 258M RAM?


More likly that you need to investigate using a better supported video
card
or a better driver. What video driver are you using?

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

You’re getting bitten by standard Neutrino-isms. So many newbies have been,
QNX should probably put up the list of these ‘isms’ on their front page…

  1. Don’t use clock() to measure precize small time intervals. I am sure QNX
    folks here will gladly jump in to explain why :wink: The syspage is your friend
    here…

  2. Your priority is getting reset every time you receive a pulse. Either set
    the priority of pulse to what you like, or disable inheriting priority from
    pulses (_NTO_CHF_FIXED_PRIORITY flag of ChannelCreate). If you’re not
    waiting for other messages, I’d suggest to use synchronous signals
    (sigwaitinfo) instead of pulses.

Once you fix those issue, your timing will be stable. And once you stop
using Photon (especially scrolling/dragging) when your realtime code runs,
everything will be fine.

– igor

“Jeff Chang” <jianjunc@cae.wisc.edu> wrote in message
news:bc7lf0$9h2$1@inn.qnx.com

The video chip I used is Chips and Technologies 65545 VGA controller,
which
is supported by QNX4.25 but not by QNX6.2.1. Since my application is an
embedded system, the video card is used now only for debugging, and will
not
be used later in the field, so is the photon.

I used -O3 option to increased the optimization level, but no big
improvments.

I think I need to describe my program more clearly as I observed something
weird while I was trying to measure the computation time of my control
loop.
Here is the control loop structure:

… // codes setting up hardware, triggering a hardware interrupt
at
100Hz, which will send a pulse back to the process
// create channel, and attach connect to the process itself.
While(1)
{
SenderPID = MsgReceive(Channel_id, &msg, sizeof(msg), NULL);

if(SenderPID == 0)
// receive the pulse, in this case it’s just from the interrupt
{
start = clock(); // record the start time;

… // all the control algorithms, and
computations


finish = clock();

duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf("%12.6f seconds,\n",duration);

}

}

I found that the printed-out ‘duration’ value is not a constant, it may be
equal to a big value, like0.004s; and may be equal to a small value, like
0.0006s. I don’t know what caused this variation in computing the same
piece
of code.

The other weired thing I observed is that, I increased the priority of the
process to 13 in the very beginning, higher than some of the photon
services. Then, while the process is running, I typed “pidin” in another
terminal to check the status of the process, and it simply displayed the
priority as “10r”. Could anybody also explain this to me a little bit?

Thanks a lot for all your inputs,
Jeff

“Chris McKillop” <> cdm@qnx.com> > wrote in message
news:bc6gbm$97l$> 1@nntp.qnx.com> …
Jeff Chang <> jianjunc@cae.wisc.edu> > wrote:
Do you think the hardware I am using consists of a problem too?

As I also find that the system is slow while I scroll down the
windows.
I am
using a PC/104+ cpumodule with 300MHz and 128M RAM. Should QNX 6 be
installed in a system with 650MHz cpu and 258M RAM?


More likly that you need to investigate using a better supported video
card
or a better driver. What video driver are you using?

chris


Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I
get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/
\

In article <bc7p3s$db8$1@inn.qnx.com>, kovalenko@attbi.com says…

You’re getting bitten by standard Neutrino-isms. So many newbies have been,
QNX should probably put up the list of these ‘isms’ on their front page…

  1. Don’t use clock() to measure precize small time intervals. I am sure QNX
    folks here will gladly jump in to explain why > :wink: > The syspage is your friend
    here…

Take a look at documentation for ClockCycles():
http://www.qnx.com/developer/docs/momentics_nc_docs/neutrino/lib_ref/c/clockcycles.html

Eduard.

“ed1k” <ed1k@humber.bay> wrote in message
news:MPG.19516d182dd99a9c9896d0@inn.qnx.com

In article <bc7p3s$db8$> 1@inn.qnx.com> >, > kovalenko@attbi.com > says…
You’re getting bitten by standard Neutrino-isms. So many newbies have
been,
QNX should probably put up the list of these ‘isms’ on their front
page…

  1. Don’t use clock() to measure precize small time intervals. I am sure
    QNX
    folks here will gladly jump in to explain why > :wink: > The syspage is your
    friend
    here…

Take a look at documentation for ClockCycles():

http://www.qnx.com/developer/docs/momentics_nc_docs/neutrino/lib_ref/c/clock

cycles.html

Eduard.

Hi Jeff

The short answer is that the new features of v6 come at a price,
performance.

Multi-threading and other features make the task swap slower and the GNU
compiler doesn’t come close to comparing with Watcom.

Make sure that your process doing the work is at the highest priority. This
may help some. Also, consider writing some of your compute intensive
routines in assembler.


“Jeff Chang” <jianjunc@cae.wisc.edu> wrote in message
news:bbqfm0$7q9$1@inn.qnx.com

I am converting a control program of a robot arm from QNX4 to Neutrino
(6.2). What puzzled me is that the same codes will take longer time for
computation in Neutrino than QNX4, and this adversely affects the
stability
of the robot arm (previous stable system becomes unstable now). The code
basically deals with reading encoders, calculating the compensation
outputs,
and output to D/A card. A hardware interrupt is used to generate a 100Hz
sampling rate. The hardware configurations are the same.



I also tried a much simpler process like just writing to the registers of
the D/A card, and it takes LONGER time for the card to react in Neutrino
than in QNX 4. Could any guru please let me know which may cause the
difference? And how to solve the problem, if possible?



Here are some information related to the computer system (any other
information are needed, please let me know):



CPU: 586 Cyrix, 299MHz, FPU; 127M memory available.



Compiler: QCC for Neutrino, Watcom for QNX4.



Priority of the Process: 10 (I increased the priority of the process, but
have no improvement)



Other processes running (blocked) concurrently:

/boot/sys/procnto

sbin/tinit

proc/boot/sloggger

sbin/mqueue

proc/boot/pci-bios

roc/boot/devb-eide

/x86/sbin/devc-con

.4/x86/sbin/fs-pkg

sbin/pipe

sbin/devp-pccard

sbin/devc-pty

sbin/devc-par

sbin/io-net

usr/sbin/spooler

sbin/devc-ser8250

sbin/devb-fdc

usr/sbin/inetd

usr/sbin/random

usr/sbin/dumper

usr/sbin/dhcp.client

usr/photon/bin/pterm

usr/photon/bin/pwm

/photon/bin/photon

photon/bin/fontsleuth

bin/sh

photon/bin/io-graphics

photon/bin/devi-hirun

usr/photon/bin/shelf

photon/bin/bkgdmgr

photon/bin/wmswitch

usr/phton/bin/saver



Thanks a lot,

Jeff