1. New & question

Hi, I'm new here.

I found once a subroutine from Rob (bytes_needed) from wich I concluded
that the sequence s defined by

        sequence s
        s = repeat( 1.1, 1024)

occupies 16 * 1024 bytes = 16 Kb (+ small overhead).

Is that really true? An atom has an accuracy of 8 bytes,
I would expect only 8Kb (+ small overhead) therefor.

Excuse my English, I'm not so used to it.

Rolf Schroeder

new topic     » topic index » view message » categorize

2. Re: New & question

errrrr
Rolf, your reply-to field is set wrong, :(
and anyone replying to your posts will not
have their reply return to the list (like
is usually expected) but instead only to you...
:/
oopsie :)

new topic     » goto parent     » topic index » view message » categorize

3. Re: New & question

Rolf Schroeder writes:
> I found once a subroutine from Rob (bytes_needed) from
> wich I concluded that the sequence s defined by
>        sequence s
>        s = repeat( 1.1, 1024)
> occupies 16 * 1024 bytes = 16 Kb (+ small overhead).
> Is that really true? An atom has an accuracy of 8 bytes,
> I would expect only 8Kb (+ small overhead) therefor.

s will occupy roughly 4 * 1024 = 4 Kb plus the space for *one*
floating-point atom. Why 4 *? Because s will consist of
1024 4-byte pointers (32-bit addresses) to a single
shared floating-point number (1.1) in memory. repeat()
will always set up shared pointers to the f.p. atom or
sequence that is repeated.

In general, floating-point atoms take more than 8 bytes, because
they also include a 4-byte reference count field, plus 4-bytes
for storage allocation overhead.

bytes_needed() assumes that no sharing takes place,
which is often wrong.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

4. Re: New & question

Still not quite clear to me:

I'm using sequences for matrix calculations and therefor would
like to estimate the memory consumption by sequences (representing
vektors
or matrices).

My question:  how many bytes will be occupied im memory (except small
overhead) by the sequence s used in the following code?

Here the code:

    constant PI = arctan(1)     -- a double presision float (8 byte)

    sequence s
    s = {}
    for i = 1 to 1024 do
        s = s & i*PI            -- 1024 different doub. pres. floats
    end for                     --   in a one-dim-sequence

Thanks, Rolf

new topic     » goto parent     » topic index » view message » categorize

5. Re: New & question

Rolf Schroeder writes:
> Still not quite clear to me:
> I'm using sequences for matrix calculations and therefor would
> like to estimate the memory consumption by sequences (representing
> vektors or matrices).
> My question:  how many bytes will be occupied im memory (except small
> overhead) by the sequence s used in the following code?
> Here the code:
>    constant PI = arctan(1)     -- a double presision float (8 byte)
>    sequence s
>    s = {}
>    for i = 1 to 1024 do
>        s = s & i*PI            -- 1024 different doub. pres. floats
>    end for                     --   in a one-dim-sequence

This example is different from the one you presented
yesterday. In the above example, all the floating-point atoms
in sequence s will have different values, so no sharing can take place.
Each f.p. atom will consume 8 bytes for the f.p. value, plus 8 bytes
of overhead for reference count & storage allocation.
So it will be 16*1024 =16K. Also the sequence s will contain
1024*4 bytes = 4K of pointers to these f.p. atoms. So the total
will be 20K.

The memory overhead for f.p. atoms is fairly high, but
suppose you are manipulating sparse matrices (most elements are 0),
or matrices where some rows are the same as other rows, or
matrices where many of the values are integers. You might save
a lot of memory. e.g.

s = repeat(repeat(i, 100), 100)
where i is an integer, will only need a sequence of
100 pointers to a single sequence of 100 4-byte integers.
i.e. about 200x4 =  800 bytes,
not the 10,000*4 = 40000 bytes
that might be needed in some other language.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu