Topic: Information about execution environment (proposed ideas?)
Author: "Vlad Harchev" <vladhar@imimail.ssau.ru>
Date: 1998/08/27 Raw View
In order to run faster, several advanced algorithms may change their
behaviour (or parameters) having the information about execution
environment. For example, float division on Pentium CPU is 39 ticks, while
multiplication is 1 to 3 ticks - so,
valarray<> implemenation for valarray<T>::operator/(T a) can prereverse the
'a' and then multiply by this value ( precission
issues should be checked in that case). On the pentium, the duration of
integer multiplication is about 10 ticks, and floating - 1-3.
So, some algorithm can prefer to use the floating type instead of integral
(if no divisions on that type will be performed)
Or, another example, if the amount of the cache memory on the chip is known,
then the algorithm can choose the optimal size of some table, etc.
I think that the following values will be useful:
* Amount of installed phisical RAM
* Amount of availble phisical RAM (?)
* Cache on the chip
* Other memory caches
* durations of arithmetic integer operations
* durations of arithmetic floating point operations
* durations of transcendental operations ( the value will be the average
duration of the function call in this case)
* may be disk memory speed, chip memory speed
These values are useful not only in C++ and C, but in other (generally
compiled) languages.
Each of listed values can't be zero - so if the corresponding value is zero,
then this means that information is not availble.
These values are preferable in several forms -
as preprocessor defines ( they will be useful in C code),
as variables (may be not const)
and (durations) as templates - such templates should have the one template
parameter - the type they describe.
* If the values are not accessible at preprocessing stage (as installed
RAM), then the macro should be undefined
(ie defined(X) will yield 0 ). Other idea - if it is defined - than it's
an average value for entire range of possible target harware.
* The durations should be as precise as possible - they should depend on the
'target CPU' setting of the compiler.
* The information about the values, provided as variable, should be
considered as most precise ( some system dependant
things will be required to initialize the variables)
* Templized version shall provide both constant (as enums or const ints) and
variable ( as static data member)
infromation about the values.
I think that some techincal report is desired on this topic ( from the C or
C++ cometee or from Open Software Foundation).
Compilers that will conform to it can be called "conforming to tech report
X.Y" or so.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]