Re: dynamically allocating memory for two dimensional array

From: Gary Funck (gary_at_intrepid_dot_com)
Date: Fri Jul 17 2009 - 13:54:22 PDT

  • Next message: Gary Funck: "Re: dynamically allocating memory for two dimensional array"
    On 07/17/09 12:25:20, Gary Funck wrote:
    > FYI. I was bit quick on the draw with that example.
    > It has "issues" that relate to array indexing.
    > More on that later.
    
    Take 2.  See attached.
    
    The issue with the previous version is that for the
    declared shared arrays, it was using UPC's normal
    thread-distributed array indexing, and that would lead to
    an incorrect implementation.
    
    This version assumes that indexing into 'a' is linear
    on the thread where 'a' (the shared vector of pointers
    to shared vectors of ints) was allocated, and that each
    vector of ints is indexed in a linear fashion on the thread
    where the vector is allocated.  In this simple example,
    everything is allocated on thread 0, but we could have
    chosen to allocate each vector on a different thread.
    
    This version differs only in the declaration of 'a':
    
        typedef shared [] int *vec_t;
        typedef shared [] vec_t *array_t;
        shared array_t a;
    
    where '[]' specifies an indefinite block size.
    
    


  • Next message: Gary Funck: "Re: dynamically allocating memory for two dimensional array"