Skip to Content.
Sympa Menu

charm - Re: [charm] Distribution of chares on PEs

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

Re: [charm] Distribution of chares on PEs


Chronological Thread 
  • From: Robert Steinke <rsteinke AT uwyo.edu>
  • To: <charm AT lists.cs.illinois.edu>
  • Subject: Re: [charm] Distribution of chares on PEs
  • Date: Sat, 27 Feb 2016 21:08:09 -0700
  • Authentication-results: lists.cs.illinois.edu; dkim=none (message not signed) header.d=none;lists.cs.illinois.edu; dmarc=none action=none header.from=uwyo.edu;
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:23

For my own code I wrote this helper function to calculate the default home PE for any index.  It works for non-powers-of-two and even if the size of the array isn't divisible by the number of PEs.

  // Calculate which PE owns a given item in a chare array.
  // The first (globalNumberOfItems % CkNumPes()) PEs
  // each have (globalNumberOfItems / CkNumPes() + 1) items.
  // The remaining PEs each have (globalNumberOfItems / CkNumPes()) items.
  //
  // Returns: the index of the PE that owns item.
  //
  // Parameters:
  //
  // item                - The index of this item.
  // globalNumberOfItems - The total number of items in the chare array.
int home(int item, int globalNumberOfItems)
{
  int numPes              = CkNumPes();                           // Number of PEs.
  int numberOfFatOwners   = globalNumberOfItems % numPes;         // Number of PEs that own one extra item.
  int itemsPerFatOwner    = globalNumberOfItems / numPes + 1;     // Number of items in each PE that owns one extra item.
  int itemsInAllFatOwners = numberOfFatOwners * itemsPerFatOwner; // Total number of items in all PEs that own one extra item.
  int itemsPerThinOwner   = globalNumberOfItems / numPes;         // Number of items in each PE that does not own one extra item.
  int itemHome;                                                   // The index of the PE that owns item.
 
#if (DEBUG_LEVEL & DEBUG_LEVEL_PUBLIC_FUNCTIONS_SIMPLE)
  if (!(0 <= item && item < globalNumberOfItems))
    {
      CkError("ERROR in home: item must be greater than or equal to zero and less than globalNumberOfItems.\n");
      CkExit();
    }
#endif // (DEBUG_LEVEL & DEBUG_LEVEL_PUBLIC_FUNCTIONS_SIMPLE)

  if (item < itemsInAllFatOwners)
    {
      // Item is owned by a fat owner.
      itemHome = item / itemsPerFatOwner;
    }
  else
    {
      // Item is owned by a thin owner.
      itemHome = ((item - itemsInAllFatOwners) / itemsPerThinOwner) + numberOfFatOwners;
    }
 
  return itemHome;
}


On 02/27/2016 01:54 PM, Alexander Frolov wrote:
Thank you very much for help! :-)

On Fri, Feb 26, 2016 at 3:24 AM, Sam White <white67 AT illinois.edu> wrote:
You can always add a print statement to your chare array element constructor with a call to CkMyPe() to find out what PE it is created on. CkMyPe() and related functions are covered in the manual here:

http://charm.cs.illinois.edu/manuals/html/charm++/2.html#SECTION01191000000000000000

And you might find this section of the manual on defining new static mappings with CkArrayMaps useful:

http://charm.cs.illinois.edu/manuals/html/charm++/13.html#SECTION02422000000000000000

-Sam

On Thu, Feb 25, 2016 at 5:45 PM, Nikhil Jain <nikhil.jain AT acm.org> wrote:
Hi Alex,

Assuming the array was created statically in one go, the default distribution for dense arrays is based on a blocked mapping, i.e. chare with index i goes to PE number (i / (total_chares/numPes)). If this is not your case, please tell us what it is.

--Nikhil

Alexander Frolov
February 25, 2016 at 14:01 via Postbox
Hi!

Sorry for asking probably very simple question. But anyway.. 

I would like to use number of PEs not equal to power of 2. How is array (array[1D]) distributed among PEs?

Thank you!

Best, 
   Alex   

--
Nikhil Jain, nikhil.jain AT acm.orghttp://charm.cs.uiuc.edu/people/nikhil Doctoral Candidate @ CS, UIUC






Archive powered by MHonArc 2.6.16.

Top of Page