Re: Revised Index versus Subscript



Note that on big-endian boxen, COMP == COMP-5 which
I did not make clear in my post.

What it all comes down to is: can you define
a subscript equivalent to an index with the attributes that apply to this
specific implemenation on this specific hardware?

And regards asm instructions -
Mostly compiler producers release according to
a platform and a OS release.
MF releases on a LCD (least common demoninator) from
supported platforms.

This means that MF does not (and can not) use eg SSE stuff
unless it is specifically targeted/required.

Roger

"Roger While" <simrw@xxxxxxxxxxxx> schrieb im Newsbeitrag
news:fddodk$i23$00$1@xxxxxxxxxxxxxxxxxxxx
While the original is getting buried with OT.

I really, really tried to keep away from this subject but ...
One of the problems with the speed2 prog is the
attempt to deduce the perform cost.
Now OC produces exactly the C code that reflects
the statements eg.
/* speed2.cob:63: PERFORM */
{
for (n0 = ((int)COB_BSWAP_32(*(int *)(b_18 + 30))); n0 > 0; n0--)
{
{
/* speed2.cob:64: EXIT */
{
goto l_5;
}
}

/* EXIT PERFORM CYCLE 5: */
l_5:;
}
}

(For those not informed, OpenCobol produces intermedaite C code)

BUT gcc (in current versions) is far more
clever and deletes the whole thing :-)

Revised test prog -
(This should be compatible with most compilers)

identification division.
program-id. speed5.
data division.
working-storage section.
01 comp5-number comp-5 pic s9(09).
01 s-subscript binary pic s9(09).
01 repeat-factor value 900000000 comp-5 pic s9(09).
01 test-byte pic x(01).

01 misaligned-area.
05 array-element occurs 4096 indexed x-index.
10 misaligned-number comp-5 pic s9(09).
10 to-cause-misalignment pic x(01).
05 byte-element occurs 4096 indexed x-index-1 pic x.

procedure division.

initialize misaligned-area

display "Start prog " function current-date
set x-index to 1000
display "Index start " function current-date
perform repeat-factor times
if x-index = 1000
set x-index up by 1
else
set x-index down by 1
end-if
move array-element (x-index) to test-byte
end-perform
display "Index end " function current-date

move 1000 to s-subscript
display "COMP start " function current-date
perform repeat-factor times
if s-subscript = 1000
add 1 to s-subscript
else
subtract 1 from s-subscript
end-if
move array-element (s-subscript) to test-byte
end-perform
display "COMP end " function current-date

move 1000 to comp5-number
display "COMP-5 start " function current-date
perform repeat-factor times
if comp5-number = 1000
add 1 to comp5-number
else
subtract 1 from comp5-number
end-if
move array-element (comp5-number) to test-byte
end-perform
display "COMP-5 end " function current-date

set x-index-1 to 1000
display "Index start " function current-date
perform repeat-factor times
if x-index-1 = 1000
set x-index-1 up by 1
else
set x-index-1 down by 1
end-if
move byte-element (x-index-1) to test-byte
end-perform
display "Index end " function current-date

move 1000 to s-subscript
display "COMP start " function current-date
perform repeat-factor times
if s-subscript = 1000
add 1 to s-subscript
else
subtract 1 from s-subscript
end-if
move byte-element (s-subscript) to test-byte
end-perform
display "COMP end " function current-date

move 1000 to comp5-number
display "COMP-5 start " function current-date
perform repeat-factor times
if comp5-number = 1000
add 1 to comp5-number
else
subtract 1 from comp5-number
end-if
move byte-element (comp5-number) to test-byte
end-perform
display "COMP-5 end " function current-date

stop run.

Note that the repeat count is pushed up, otherwise the results are
statistically meaningless.Tests repeated 5 times with +- 1/100 second
difference.

Results from Linux boxen (in single-user mode)
(As all benchmarks should be done on 'nix systems)
(32 bit is P4 prescott with 3.2GhZ)
(64 bit is P4 650 3.4 GhZ)

MF SE 2.2 (Linux x86 32 bit)
cob -u -O -C notrunc -C sourceformat=free speed5.cob
cobrun speed5
Start prog 2007092612363397+0200
Index start 2007092612363397+0200
Index end 2007092612363681+0200
COMP start 2007092612363681+0200
COMP end 2007092612364047+0200
COMP-5 start 2007092612364047+0200
COMP-5 end 2007092612364361+0200
Index start 2007092612364361+0200
Index end 2007092612364672+0200
COMP start 2007092612364672+0200
COMP end 2007092612365034+0200
COMP-5 start 2007092612365034+0200
COMP-5 end 2007092612365357+0200

OC 0.33 current -
cobc -x -O2 -std=mf -free speed5.cob
./speed5
Start prog 2007092612311407+0200
Index start 2007092612311407+0200
Index end 2007092612311690+0200
COMP start 2007092612311690+0200
COMP end 2007092612312044+0200
COMP-5 start 2007092612312044+0200
COMP-5 end 2007092612312326+0200
Index start 2007092612312326+0200
Index end 2007092612312609+0200
COMP start 2007092612312609+0200
COMP end 2007092612312963+0200
COMP-5 start 2007092612312963+0200
COMP-5 end 2007092612313246+0200

OC 0.33 current on Linux x86_64 (64 bit)
cobc -x -O2 -std=mf -free speed5.cob
./speed5
Start prog 2007092612285455+0200
Index start 2007092612285455+0200
Index end 2007092612285602+0200
COMP start 2007092612285602+0200
COMP end 2007092612285855+0200
COMP-5 start 2007092612285855+0200
COMP-5 end 2007092612290004+0200
Index start 2007092612290004+0200
Index end 2007092612290135+0200
COMP start 2007092612290135+0200
COMP end 2007092612290366+0200
COMP-5 start 2007092612290366+0200
COMP-5 end 2007092612290497+0200

Now as to what has all been said in this thread, then I have the
following comments -
COMP (aka BINARY) is stored as big-endian by all
compilers these days.
Therefore there is a penalty on little-endian machines
(or better the OS/firmware for eg. bi-endian) to
byte-swap, operate and re-byteswap results.
This, of course, affects eg. x86(_64).
However, see below

Alignment -
There are in fact not that many alignment tolerant machines there.
Intel x86(_64) and Power PC are known. (The Itanium is not)
This means that any reference to a COMP/COMP-5 item must
be moved to an intermediate area unless it can be proved at compile
time that it is appropiately aligned. (eg. at 01 level)

So we have to look at a bisection of the above two attributes.
Generally speaking, for performance, (other than INDEX)
one should use COMP-5 (aka BINARY-LONG SIGNED/UNSIGNED)
for subscripts/counters etc. and define them at the 01 level.

Not only that, a particular compiler implementation has it's
own INDEX definition which is somewhat difficult to ascertain.
(And which is not necessarily a C-5 item)

Roger






.



Relevant Pages