Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: [hwloc-devel] What does this C99 notation mean?
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2011-02-11 21:04:25


In distances.c, I see:

static void
hwloc_setup_groups_from_distances(struct hwloc_topology *topology,
                                  unsigned nbobjs,
                                  struct hwloc_obj **objs,
                                  float *_distances)
{
  float (*distances)[nbobjs][nbobjs] = (float (*)[nbobjs][nbobjs])_distances;

As far as I can tell, _distances is a 1D array of floats, but it is of size (nbobjs*nbobjs) -- i.e., you could think of it as a 2D array, and index the i'th column in the j'th row at _distances[i * nbobjs + j]. From how its used in the code, distances is treated as a 2D array -- i.e., distances[i][j] is accessed.

I have a bunch of guesses as to what this means, but none of them seem quite right, so I figured I just ask -- what the heck does that declaration statement mean?

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/