www.digitalmars.com         C & C++   DMDScript  

D - OpenMP, and set

I hope, i didn't make a mistake with that name.

OpenMp are C using a some #pragma to automatically made parrallel code.
It's used for highly parrallel computer (more than 1000 cpu) or for
computer farm. It's the langage the most appreciate today for parrallel
computing (compare to HPF (too slow) or message based library lioke PVM
or ...(i forget the name) (code bloat) ). It's appreciate because of the
simplicity of the C (the code could be reused with normal compiler on a
normal machine). And then you could add some "pragma hint" to help the
compiler to better parrallelising the code.

Why puting such thing in D ? Because all new cpu could execute many
instructions per cycle : 5 for the Pentuim III, 6 or 9 for current IA64.
Beside that, the new cpu introduice "multimedia extention" as MMX or
SSE, which are SIMD instructions (for example, multiplying 2 packet of 4
32 bits floating point number to give back a packet). In one or 2 years,
will come some cpu with 2 cpu core on the same die (on the same chip),
it's what is plane by AMD.

Intel write very powerfull C compiler to use all this feature not
provide by the C at the beginning.

OpenMP provide some hint to describe how the data should be dispatch,
which data should stay private to each process, which one are global to
the system. (OpenMp are based on the fact that "something" simulate a
shared memory computer but the hint greatly improved performance).

Beside that, i think that new langage should more _describe_ what the
user want to do rather than how to do it. So the compiler should compile
code to the best for each cpu. It will be great not to have so many
flags for compiling : the code should be enough. We compile only for
debugging or for release. So it should have only 2 switchs.

I have learn some langage as CASL or Machine B. This 4th generation
langage are used to make prove on it. (you give a fact, and a prover say
it's true or not). Make prove on C is very difficult because of the
pointer and the "infinite" memory model. 

This kind of langage are based on mathematical finite set (ensemble in
french). So prove became possible. At least, for debugging it could be
useful to say : that variable are include in that set. It's very
different from usual type but much more powerfull.

int8 i;
could be 

i N[0..15] (N are natural)

float :
fp R[0.0..15.0] (+ precision hint : a letter ? ) (R for real, but why
not F but float are 32 bits for most of the user)

So if the used processor have very few memory, only 4 bits need to be
used. Beside that, a statical analyse of the code (i'm not saying it's
easy ! ), could say : "Error, in that case, variable foobar will get out
of his set". That is possible only because we manipulate finite set and
not inifinite like is supposed to be in C. At least, a debug mode could
just take care that some value are never reached.

In case of rewriting loops, it could interresting to know how much a
loop will be performed. If a loop run 5 to 8 times, it could not
interresting to vectorise it (too much overhead to finish cleanly). But
if the loop is always run around 10000, it's very interresting to
vectorise it because the overhead are negligeable. The same thing could
be used to perform strip mining properly (cut a loop into piece to
increase the locality of the data, so to work as much as possible with
the memory cache).

I don't know how to keep C compatibility but new type will be simply to
defined a new set. Some thing funny with set is that is possible to
defined set of set...

nicO
Aug 22 2001