Re: Computer programmers' habits in electronics
- From: "PeteS" <ps@xxxxxxxxxxxxxxxxxxx>
- Date: 21 Dec 2005 01:27:34 -0800
Geoff Joy wrote:
> On 20 Dec 2005 15:00:45 -0800, "PeteS" <ps@xxxxxxxxxxxxxxxxxxx> wrote:
>
> >Geoff wrote:
> >> On 20 Dec 2005 11:24:45 -0800, "PeteS" <ps@xxxxxxxxxxxxxxxxxxx> wrote:
> >>
> >> >I love the C construct 'where(x)' :)
> >>
> >> There's a 'where(x)' construct in C? How is it implemented?
> >> Where is this documented?
> >>
> >> Surely you mean "while(x)", yes?
> >>
> >
> >
> >> Methinks you have been programming Fortran or LISP too much.
> >
> >Done both, enjoyed them.
> >
> >Although I answered, perhaps you should consider carefully reading
> >everything I wrote. I mentioned it was a massively parallel system
> >(well, 320 parallel, anyway) and a construct such as 'where(something)
> >is perfect in a parallel SIMD world.
> >
> >I actually wrote that I loved the C 'where(x) construct'. There was no
> >mention of it being ANSI C ;)
> >
> >Cheers
> >
> >PeteS
>
> And I did consider everything you wrote. Which is why I asked how it
> was implemented since as a function, where() would have had to have
> been exactly that, a function. Your choice of the word "construct"
> keyed me into that. Strictly speaking, "while" is a keyword, not a
> construct or a function call.
>
> Now, what's the difference between
>
> where(x == active)
> {
> do_something;
> }
For each processor where x evaluates true, do something. For those
processors where x evaluates false, do no-ops until end of statement.
Note that this is a parallel 'if' statement,
>
> and
>
> while(x == active)
> {
> do_something;
> }
On all processors, do something, but loop. The where statement is not a
loop.
>
> and why did it require creating a new keyword?
The where keyword (which was added for the parallel compiler we used)
permits the evaluation of a variable on a per processor basis. Very
useful in sending data streams or error messages, amongst many other
things
for instance
where (PROCNUM == 0)
{
printf("Some error message");
}
prints one instance of the error message (from processor 0), while
if(error) printf("Some error message");
causes all processors to print an error message, which gets a little
untidy ;)
Cheers
PeteS
.
- References:
- Re: Computer programmers' habits in electronics
- From: Jim Thompson
- Re: Computer programmers' habits in electronics
- From: Dirk Bruere at Neopax
- Re: Computer programmers' habits in electronics
- From: PeteS
- Re: Computer programmers' habits in electronics
- From: PeteS
- Re: Computer programmers' habits in electronics
- Prev by Date: Re: I'm surprised...
- Next by Date: Wireless speakers design
- Previous by thread: Re: Computer programmers' habits in electronics
- Next by thread: Re: Computer programmers' habits in electronics
- Index(es):
Relevant Pages
|