A preprocessor macro is just a text substitution: the right hand part gets substituted for the left hand part before the code gets to the compiler. So any occurrence of the characters "twofiftysix" downstream of "#define twofiftysix 256" gets replaced with the characters 256. It's basically...
...
double result( init_val);
gettimeofday( &t_begin, &tz);
for(size_t i = 0; i < maxit; ++i)
{
result = result/(result+c);
}
gettimeofday( &t_end, &tz);
// The next line prevents the compiler from eliminating the above loop.
// It does not contribute to the measured time...
You can prevent that by using the result of the calculation in a way that the optimizer must honor. The easiest way to do that is to print it; the second easiest, though less certain as inter-procedural optimizers improve, is to insert the loop into a function.
As Jeff and AlephZero point out, performance depends on hardware, compiler, code, and the algorithm.
If you write your program to run on a relatively recent x86/x86-64 machine using vector (packed) SSE, you might see a sharp difference between 32 and 64 bit FP. This is because there are two...
I was able to build using GCC 4.2. As far as I understand, GCC did not support openmp prior to 4.2 (although some people built it into 4.1 on a provisional basis, e.g. fedora core 5/6).
I built GCC 4.2, than ran
/my/gcc4.2dir/gfortran -fopenmp hello_f77.f
with GCC 4.2 directories...
I hadn't compared a vector-of-vectors matrix to a matrix in a flat vector in several years, so I just wrote an integer matrix-vector multiply both ways. I was surprised by the results: the difference in run time was <~ 1%. Run 1000 times for a 1000x2000 matrix, the flat vector matrix took 3.68...
Strikwerda's "Finite Difference Schemes and Partial Differential Equations" is a general introduction to finite difference methods, with a lot of coverage of convergence, stability, etc.
w3schools.com has tutorials for beginners on HTML & XHTML, writing web pages, etc. They also have tutorials on scripting for both the browser and server sides.
I learned from "C The Complete Reference" by Herb Schildt. You might also look at "Teach Yourself C" by the same author. And I learned a lot of basic C++ from "C++ Primer Plus", so I can recommend the author Prata (same as C Primer Plus).
Java doesn't seem to be used much in physics/astrophysics HPC. I suspect Java does not have much to offer that C++ or the newer Fortran flavors don't have already. The thinking may be, with a lot of existing code already written in those languages, why use Java?
Reading the IBM paper you...
Floating point math is non-associative. More aggressive optimization levels permit the compiler to reorder operations, thus leading to different results.
You're counting on two numbers being identical except for sign and thus perfectly cancelling. That's not happening, indicating that...