Hello Vassily,
thank you for your answers.
 
I've just noticed that it seems that the array is not "really" reallocated. It rather looks like it were expanded (because the old values are still in the array after reassigning the domain). Does that mean that chapel is reallocating memory and copying the old values automatically? Or will it only allocate new memory and redirecting invocations to the new array indices to the new memory that were allocated?
E.g.: if I have an array with two 32-bit integers then I assume that the memory allocated belongs together:
address of myIntArray(0) = 0x000000000050
address of myIntArray(1) = 0x000000000054

Now I'm reassigning the arrays domain to 0..2 ... do I get new memory allocation now, but all belonging together:
address of myIntArray(0) = 0x7fffffffff50
address of myIntArray(1) = 0x7fffffffff54
address of myIntArray(2) = 0xffffffffff58
 
or are only the first two indices together and the third were only allocated new:
address of myIntArray(0) = 0x000000000050
address of myIntArray(1) = 0x000000000054
address of myIntArray(2) = 0xffffffffff58
 
I'm just asking because it would mean that my program gets a lot of cache misses if I'm reassigning the domain too much often during my calculations and may rather allocate a much bigger array in the beginning although I probably won't need the space.
 
Best regards,
Marco
 
Gesendet: Mittwoch, 04. Februar 2015 um 01:05 Uhr
Von: "Vassily Litvinov" <[email protected]>
An: "Marco Postigo" <[email protected]>
Cc: [email protected]
Betreff: Re: Questions about randomFill and array reallocation
To follow up on my previous response:

* (as I mentioned) the correct way to resize an array is to update its
domain variable, in this example:

lifelinesDomain = 0..(p.z-1);

* Currently our compiler also allows you to update lifelines.domain
directly. This is a bug, do not rely on it.

* 1-D arrays also support vector operations. See the following file for
examples and limitations:

$CHPL_HOME/examples/primers/arrayVectorOps.chpl

Vass

On 01/29/15 15:04, Marco Postigo wrote:
> Hello,
> I have some questions about the randomFill(x:[]) function and array reallocation.
> First of all I need to use the Random Module and I'm not sure what the interval
> is of the numbers returned... I've found in a paper where it was stated that it
> returns values between 0 and 1... inclusive? exclusive?
> Is it as in most other languages [0, 1) or are both incluse ( -> [0, 1] )?
> Second is the reallocation of arrays... I haven't found any examples so I've
> tested a bit around and only got it worked with using a domain and reassigning
> it. Is this the correct way or is there another "nicer" solution?
> code snippet:
> 9 /** Domain of lifeline buddies array */
> 10 var lifelinesDomain : domain(rank=1) = 0..0;
> 11 /** Lifeline buddies */
> 12 var lifelines : [lifelinesDomain] uint;
> ...
> 55 lifelinesDomain = 0..(p.z-1); // reallocation in constructor
> Sorry if this questions are duplicates or if I've just overlooked the solution
> in your spec / docs.
> Kind regards,
> Marco
 
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to