Finally full multidimensional arrays support in D

Stefan Frijters via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 16 12:32:08 PDT 2014


On Monday, 17 March 2014 at 17:39:41 UTC, Denis Shelomovskij 
wrote:
> Multidimensional arrays indexing and slicing syntax is finally 
> added [1] (thanks to Kenji Hara). So it was a good cause to 
> update my multidimensional arrays library implementation and 
> add support for the new syntax. So here we are: [2].
>
> Also should we add it to the standard library?
>
> [1] https://github.com/D-Programming-Language/dmd/pull/443
> [2] 
> http://denis-sh.bitbucket.org/unstandard/unstd.multidimarray.html

First of all, thank you very much for making such nice additions 
to D available for general use. I finally got around to giving 
this a spin. I'm using it for a proof-of-context HPC simuation 
code written in D (currently mostly experimenting with D's 
features), and as such I'm interfacing with the C MPI library to 
communicate between processes. The basis of the simulation is a 
3D lattice, so I was eagerly awaiting a nice solution in D. So 
far I've run into two things while using your library. The first 
is that I need to provide void pointers to the data to the MPI 
functions, so I currently hacked your code to make the _data 
storage array publicly accessible and that seems to work. To give 
an idea, I currently have code like this (just a snippet):

arr = multidimArray!T(nxH, nyH, nzH);
// [...] fill the array with data
// Prepare a buffer to receive a slice from another process.
rbuffer = multidimArray!T(haloSize, nyH, nzH);
// Prepare a buffer to send a slice to another process.
sbuffer = arr[$-2*haloSize-1..$ - haloSize-1, 0..$, 0..$].dup;
// Here I now use the pointer of the storage arrays to send the 
buffer around.
MPI_Sendrecv(sbuffer._data.ptr, nyH * nzH, MPI_INT, M.nbx[1], 0, 
rbuffer._data.ptr, nyH * nzH, mpiType, M.nbx[0], 0, M.comm, 
&mpiStatus);
// Put the buffer in the correct spot in the main array.
arr[0..haloSize, 0..$, 0..$] = rbuffer;

Am I missing a nicer way to accomplish this? I like the 
compactness of the code (compared to what I'm currently used to 
with our F90 simulation code). Secondly, the property that 
returns the dimensions of the array is called 'dimentions' (with 
a t), this should be fixed.

Regards,

Stefan


More information about the Digitalmars-d mailing list