Skip to Content.
Sympa Menu

charm - [charm] user defined array indices

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] user defined array indices


Chronological Thread 
  • From: "Mitchell, John A" <jamitch AT sandia.gov>
  • To: "charm AT lists.cs.illinois.edu" <charm AT lists.cs.illinois.edu>
  • Cc: "Mitchell, John A" <jamitch AT sandia.gov>
  • Subject: [charm] user defined array indices
  • Date: Wed, 7 Jun 2017 00:27:10 +0000
  • Accept-language: en-US

Hi,


I am having trouble understanding how to use 'user defined array indices';

  • I am using indices to insert into an array.  after all insertions I use 'array.doneInserting'
  • array [LeafId] Leaf { ... };
  • My indexing class is below;
  • Can temporary (short lived) LeafId instances be used to index.
  • What I don't understand is what makes each user index unique?  
  • Code below errors out with:
  • ------------- Processor 0 Exiting: Called CmiAbort ------------
    Reason: Cannot insert array element twice!

thanks,

John


// Insert leaves using indices defined below.  Note 'id' only exists insides braces and will disappear quickly since its a temporary variable.

{

LeafId id(level+1,path+1);      
leaves[id].insert(right_tree_size,right_points,thisProxy,span_right_pup);

}


// My user defined indexing class

class LeafId {

   private:
      ordinal_type level, path;
   public:

      LeafId(ordinal_type l, ordinal_type p) : level(l), path(p) { }

      bool is_left() const { return 0==path%2; }
      bool is_right() const { return 1==path%2; }

      ordinal_type cardinality() const {
         ordinal_type id=1;
         for(int i=1;i<=level;i++)
            id*=2;
         return id+path;
      }   

};

class CkArrayIndexLeafId :public CkArrayIndex {
   public:
      CkArrayIndexLeafId(const LeafId& l) {
         nInts=2;
      }   
};



  • [charm] user defined array indices, Mitchell, John A, 06/06/2017

Archive powered by MHonArc 2.6.19.

Top of Page