POV-Ray : Newsgroups : povray.advanced-users : Array irritation. Server Time
30 Jul 2024 04:11:57 EDT (-0400)
  Array irritation. (Message 21 to 27 of 27)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Lutz Kretzschmar
Subject: Re: Array irritation.
Date: 19 Oct 2000 09:28:20
Message: <tpttusgkh5soek049ibglpo603576eh6un@4ax.com>
Hi Warp, you recently wrote in povray.advanced-users:

>   Why would he do that?
Because he found that float was not precise enough?

- Lutz
  email : lut### [at] stmuccom
  Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Ron Parker
Subject: Re: Array irritation.
Date: 19 Oct 2000 09:57:32
Message: <slrn8utvee.2rv.ron.parker@fwi.com>
On 19 Oct 2000 09:22:29 -0400, Warp wrote:
>Ron Parker <ron### [at] povrayorg> wrote:
>: It might pipeline better.
>
>  AFAIK instructions that handle the same register can't be executed in
>different pipelines at the same time (at least this in a Pentium).

That's probably true, but a load-modify-store sequence might be more easily
run in parallel with another such sequence.  Of course, if that's the case,
they would have microcoded inc as such a sequence.  I suspect the real 
reason your compiler built it that way is the second reason I gave.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Array irritation.
Date: 19 Oct 2000 10:59:44
Message: <39ef0c60$1@news.povray.org>
In article <39eeabab@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   Sparc.
>   The assembler instruction I wrote in my article was fictitious
> (pseudo-assembler). It's not Sparc assembler.

OK.  I was asking because I was interested if Sparc supports rotations in
hardware.

> : What is this program doing?
>
>   No idea.
>   A wild guess: Either a multiplication or a division?

Good guess, it is a multiplication.  It plays around with bit patterns and
overflows to be able to accomplish the result in only 4 registers.


     Thorsten


PS: Division (recursive) could look like this ...

 addi $3, $3, 4
 addi $1, $1, 47
 sw   $1, 0($0)
 sw   $0, 1($3)
 addi $1, $0, 10
 sw   $1, 2($3)
 addi $1, $0, 1
 sw   $1, 3($3)
 jal  $1, sub
 lw   $1, 0($3)
 lw   $2, 1($3)
 lw   $2, 0($2)
wait:
 j wait
sub:
 sw   $1, 4($3)
 lw   $1, 2($3)
 subi $2, $0, 1
 beq  $1, $0, ret
 lw   $2, 1($3)
 lw   $2, 0($2)
 slt  $2, $2, $1
 subi $2, $2, 1
 beq  $2, $0, ret
 lw   $2, 1($3)
 sw   $2, 6($3)
 lw   $2, 2($3)
 sll1 $2, $2
 sw   $2, 7($3)
 lw   $2, 3($3)
 sll1 $2, $2
 sw   $2, 8($3)
 addi $3, $3, 5
 jal  $1, sub
 subi $3, $3, 5
 lw   $2, 5($3)
 sw   $2, 0($3)
 lw   $1, 2($3)
 lw   $2, 1($3)
 lw   $2, 0($2)
 slt  $2, $2, $1
 bne  $2, $0, ret_now
 lw   $2, 1($3)
 lw   $2, 0($2)
 sub  $2, $2, $1
 lw   $1, 1($3)
 sw   $2, 0($1)
 lw   $2, 0($3)
 lw   $1, 3($3)
 or   $2, $2, $1
ret:
 sw  $2, 0($3)
ret_now:
 lw  $1, 4($3)
 jr $1


// calculates x / y
int sub(int *x, int y, int cnt);

int main()
{
 int x = 47;
 cout << sub(&x, 4, 1) << "\n";
 cout << x << "\n";
 return 0;
}

int sub(int *x, int y, int cnt)
{
 int temp;
 if(y == 0)
  return -1;
 if(*x < y)
  return 0;
 temp = sub(x, y << 1, cnt << 1);
 if(*x >= y)
 {
  *x -= y;
  temp |= cnt;
 }
 return temp;
}


Post a reply to this message

From: ian mcdonald
Subject: Re: Array irritation.
Date: 19 Oct 2000 15:21:28
Message: <39ef49b8@news.povray.org>
First my apologies to the group for not responding in two days. I have been
working and not much else. I now know what 1,200mg of caffine does to the
human body. : (

I discovered my problem when I read Michael Andrews post, telling me that
the arrray is not as one would expect. I thought having an array of [N][N]
would mean I had an array of that precise size, and not [N-1][N-1].

That was my entire problem. Povray did not like the fact that I was calling
the array with the values it was defined with. My loops went from 3 to 1 and
10 to 1, not 2 to 0 and 9 to 0.

My thanks to the group for your help.

ian

Michael Andrews <M.C### [at] readingacuk> wrote in message
news:39EC99EF.283EA738@reading.ac.uk...


Post a reply to this message

From: Warp
Subject: Re: Array irritation.
Date: 22 Oct 2000 10:22:17
Message: <39f2f818@news.povray.org>
Lutz Kretzschmar <lut### [at] stmuccom> wrote:
:>   Why would he do that?
: Because he found that float was not precise enough?

  Wouldn't a

typedef double DBL;

be better and easier to do?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Lutz Kretzschmar
Subject: Re: Array irritation.
Date: 24 Oct 2000 04:26:42
Message: <p5d9vs0894vnrsndusf589uk7muts9j6rh@4ax.com>
Hi Warp, you recently wrote in povray.advanced-users:

> typedef double DBL;
Yes, it would, I guess. Your guess is as good as mine about why
someone would write the example you quoted in the first place, you
certainly wouldn't find a construct like that in my code <g>......

- Lutz
  email : lut### [at] stmuccom
  Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Warp
Subject: Re: Array irritation.
Date: 24 Oct 2000 04:36:54
Message: <39f54a26@news.povray.org>
For things like this, look at:

http://web2.airmail.net/~sjbaker1/software/horrors.html

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.