[Beowulf] ***UNCHECKED*** Re: Re: Re: [EXTERNAL] Re: Re: Spark, Julia, OpenMPI etc. - all in one place

Lux, Jim (US 7140) james.p.lux at jpl.nasa.gov
Tue Oct 20 09:52:17 PDT 2020



From: Prentice Bisbal <pbisbal at pppl.gov>
Date: Tuesday, October 20, 2020 at 9:40 AM
To: John Hearns <hearnsj at gmail.com>, Jim Lux <james.p.lux at jpl.nasa.gov>
Cc: "Renfro, Michael" <Renfro at tntech.edu>, "beowulf at beowulf.org" <beowulf at beowulf.org>
Subject: Re: [Beowulf] ***UNCHECKED*** Re: Re: [EXTERNAL] Re: Re: Spark, Julia, OpenMPI etc. - all in one place


Indexing from zero - who ever heard of zero of a thing. Damn quiche eaters.

I've heard it explained this way: Index zero requires zero offset from the start of the array's memory address, so the index presents how many offsets the item is away from the start of the array.

Makes more sense when you think of it that way. But again, it makes more sense in lower languages like C than it does in "higher" languages like Fortran and Python where memory addressing details aren't exposed to the programmer.

Prentice

Exactly – it’s a nice thing in C, because C isn’t really implementing arrays per se, the Array variable is a pointer, and the a[i] notation is basically a shorthand for pointer arithmetic. And it’s close to the target executable. I think, when C was first developed, folks weren’t worrying about optimizers, for instance.

You can do horrible things like

int a[100];

/* some code */

a[i] = *(a+j);        /* someone using both array style and pointer style references, just because they can */

and

a = &somehexconstant;

Handy for mapping to a buffer of characters at some address, but full of traps for the unwary




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://beowulf.org/pipermail/beowulf/attachments/20201020/edd7f542/attachment.html>


More information about the Beowulf mailing list