Topic
3 replies Latest Post - ‏2010-06-12T07:56:38Z by NLai
NLai
NLai
14 Posts
ACCEPTED ANSWER

Pinned topic Delete ptObject; //Problem

‏2010-06-08T21:05:45Z |
Hi dear,
can someone help.

1)
aClass anObject;
anObject.aMemberFunction; //Work greatly

2)
aClass *ptObject=new aClass;
ptObject->aMemberFunction;
//delete ptObject; //Work greatly, only worry cannot free some memory for other programs

3)
aClass *ptObject=new aClass;
ptObject->aMemberFunction;
delete ptObject; //Work until the program ends, then the terminal displays:
segment failure.
Memory map:
.........
//in full screen

4)
I am using g++ to compile the program, if I am using only spe's vector registers, it runs smoothly; but if I also include ppe's vector registers, it sometimes work well, but sometime even cannot go through the compiler in saying:

illegal instructions: -mno-string -mno-multiple -maltivec -mabi=altivec

I am using IBM SDK 3.? on PS3, it runs greatly overall.

Thanks.
Updated on 2010-06-12T07:56:38Z at 2010-06-12T07:56:38Z by NLai
  • kenws
    kenws
    49 Posts
    ACCEPTED ANSWER

    Re: Delete ptObject; //Problem

    ‏2010-06-09T07:40:00Z  in response to NLai
    NLai,
    It's not clear to me whether your snippets are referring to SPU or PPU code. You mentioned that you're using g++ (which indicates PPU) but you're also saying your code is using SPU registers. It might help to attach an example that illustrates the issue.
    -ken
    • NLai
      NLai
      14 Posts
      ACCEPTED ANSWER

      Re: Delete ptObject; //Problem

      ‏2010-06-12T07:09:48Z  in response to kenws
      Thanks Ken,
      my code is for ppu

      int main(int argc, char **argv){
      .........
      double (*spuRDbl)SIZE/8 __attribute__ ((aligned(128)));
      unsigned char (*spuIRcd)SIZE __attribute__ ((aligned(128))); //Trans into the SPU's LSs
      unsigned short int (*spuUInt)SIZE __attribute__ ((aligned(128))); //Trans back from the LSs
      .........
      spuIRcd=new unsigned charSFNSIZE;
      spuUInt=new unsigned short intSFNSIZE;
      spuRDbl=new doubleSFNSIZE/8; //Rtn: upto 128 doubles
      .........
      //delete] spuRDbl; delete[ spuUInt; delete[] spuIRcd;
      return 0;
      }//end.

      I would like to free the dynamic double arrays by the end of the program.
      I did not use new ... delete in spu code, since I thought the stack there could be limited if not overlap the heap.

      However, spu's vector registers run well. ppu's vector registers sometimes run well, sometimes even cannot go through the compiler when I modify only a bit the code when use g++, actually is ppu-g++ and spu-g++.

      Cell is a great interesting cpu, it seems in my program around 3 spus equal a 1.9GHz G5 in double floating point operation, is that right?
      • NLai
        NLai
        14 Posts
        ACCEPTED ANSWER

        Re: Delete ptObject; //Problem

        ‏2010-06-12T07:56:38Z  in response to NLai
        some funny things appeared on my post, I got to retype again:

        enum{SIZE=1024};
        int main(int argc, char **argv){
        .........
        double (*spuRDbl)SIZE/8 __attribute__ ((aligned(128)));
        unsigned char (*spuIRcd)SIZE __attribute__ ((aligned(128))); //Trans into the SPU's LSs
        unsigned short int (*spuUInt)SIZE __attribute__ ((aligned(128))); //Trans back from the LSs
        .........
        spuIRcd=new unsigned char32SIZE;
        spuUInt=new unsigned short int32SIZE;
        spuRDbl=new double32SIZE/8;
        .........
        //delete] spuRDbl; delete[ spuUInt; delete[] spuIRcd;
        return 0;
        }//end.