Skip to Content.
Sympa Menu

charm - Re: [charm] [EXTERNAL] Re: user defined array indices

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

Re: [charm] [EXTERNAL] Re: user defined array indices


Chronological Thread 
  • From: Matthias Diener <mdiener AT illinois.edu>
  • To: "Mitchell, John A" <jamitch AT sandia.gov>
  • Cc: <charm AT lists.cs.illinois.edu>
  • Subject: Re: [charm] [EXTERNAL] Re: user defined array indices
  • Date: Tue, 13 Jun 2017 19:32:17 -0500

Hi John,

I did some more tests and I believe I found the problem.

In general, there are no issues with the following way to insert
indices (based on a short-lived "f" object):

for (int i=0; i<nElements; i++) {
LeafId f(i,0);
arr[f].insert();
}

However, the CkArrayIndexLeafId class needs to store the actual index object:

class CkArrayIndexLeafId :public CkArrayIndex {
LeafId *idx;
public:

CkArrayIndexLeafId(const LeafId &f)
{
idx = new(index) LeafId(f);
nInts=2;
}
};

When removing the line that allocates "idx", the program crashes in
the way you described in your initial message. Might this be the issue
you saw?

Regards,
Matt

On 13 June 2017 at 17:00, Mitchell, John A
<jamitch AT sandia.gov>
wrote:
> Matt,
>
> Thanks for you efforts.
>
> The full code is too complicated to post. I can try and create a simpler
> example using the LeafId class I did post to see if it will still have that
> problem.
>
> Can you say anything about the difficulties you are having? Did you try
> and use my user index LeafId class in your effort and had no problem? What
> causes that error to occur? How are user indices unique?
>
> Thanks,
> John
> ________________________________________
> From: Matthias Diener
> <mdiener AT illinois.edu>
> Sent: Tuesday, June 13, 2017 3:49 PM
> To: Mitchell, John A
> Subject: [EXTERNAL] Re: [charm] user defined array indices
>
> Hi John,
>
> I am having difficulties to replicate your example. Could you please
> post the full code?
>
> Thanks,
> Matt
>
> On 6 June 2017 at 19:27, Mitchell, John A
> <jamitch AT sandia.gov>
> wrote:
>> 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;
>> }
>> };
>>



Archive powered by MHonArc 2.6.19.

Top of Page