UPC Dynamic Memory Data Layout Problem

From: Andrew A. Johnson (ajohn_at_ahpcrc_dot_org)
Date: Wed Feb 02 2005 - 14:48:54 PST

  • Next message: Dan Bonachea: "Re: UPC Dynamic Memory Data Layout Problem"
    I have a quick UPC question involving shared arrays
    and dynamic memory allocation.  In the examples, to
    create a sharred array of size "N", I can do:
    
         shared [N/THREADS] int array[N];
    
    For example, if N is 9 and THREADS is 3 (i.e. 3 processors),
    this would give me a 1D array with the layout
    
        array[0]  -> affinity to 0
        array[1]  -> affinity to 0
        array[2]  -> affinity to 0
        array[3]  -> affinity to 1
        array[4]  -> affinity to 1
        array[5]  -> affinity to 1
        array[6]  -> affinity to 2
        array[7]  -> affinity to 2
        array[8]  -> affinity to 2
    
    so it is basically a 1D array, split evenly
    into chunks of THREADS processors.
    
    Ok, in most application codes (and the big
    new code I'm contemplating use with UPC), N
    is never known at compile time, and is a
    user-input variable for the size of the data set
    (i.e. the total length of this 1D array I want).
    
    My question is, How do I get this same data layout
    when "N" is a variable only known at run time?
    
    I've been trying to use pointers and the upc
    dynamic memory allocation functions, but having
    trouble getting it to lay-out the data this way.
    
    I'm using the UPC compiler on the Cray X1,
    if that helps...
    
    Thanks,  Andrew
    
    -- 
    Andrew A. Johnson, Ph.D.
    Army HPC Research Center / NetworkCS, Inc.
    612.337.3415   ajohn_at_ahpcrc_dot_org
    

  • Next message: Dan Bonachea: "Re: UPC Dynamic Memory Data Layout Problem"