[Beowulf] Stroustrup regarding multicore
Perry E. Metzger
perry at piermont.com
Tue Aug 26 08:05:48 PDT 2008
"Michael H. Frese" <Michael.Frese at NumerEx-LLC.com> writes:
> C is not much better. I once worked a young computational programmer
> for almost a week to get him to prove to himself that a C source
> program couldn't walk through a 2-d array the hard way as fast as a
> Fortran source program unless the stepping was coded by hand.
I don't understand what that means. I've been programming in C for
about 25 years, and I have known Fortran since the mid-1970s.
> He didn't believe that a 2-d array in C is syntactically a 1-d array
> of pointers to 1-d arrays,
He was right. You are just plain wrong.
char foo[10][10]
allocates 100 consecutive addresses in memory.
In case you don't believe me, try out the following program:
----------------------------------------------------------------------
#include <stdio.h>
char foo[10][10];
int main(int argc, char **argv)
{
int i, j;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
printf("%d\n", &(foo[i][j]));
}
----------------------------------------------------------------------
It will print 100 consecutive integers, the addresses of the character
array elements.
> and the row pointers must be fetched from memory!
I call bull. That's just totally false. You clearly don't know how C
works.
> And separate compilation of functions with variable array
> dimensions? I hear echoes of Kernighan and Ritchie laughing with each
> other "We don't need no steenking libraries with execution-time array
> dimensioning! We're system programmers here! Besides, if somebody
> needs that they'll use Fortran."
Er, you can do that, too. Works just fine. What *are* you talking
about?
Perry
More information about the Beowulf
mailing list