[ADOL-C] Memory problem

Martin Friedmann friedmann at sim.tu-darmstadt.de
Tue Apr 5 07:21:57 EDT 2011


Hi there,

I have a somewhat strange problem which may be related to my limited knowledge of ADOL-C, nevertheless I would very much appreciate your help :-)

Lots of memory seem to be allocated (until the program crashes) during runtime of the following program the program also gets increasingly slow during runtime. Please note that in this program never a tape is written, and no adoubles are allocated after calling the setup() function. Most interestingly, the issue goes away, if I do comment out the first line of setup().

I believe that this problem is caused because the automatic variable is allocated _before_ the huge array is allocated, but freed automatically _after_ creation of the array.

Any help is welcome! And yes -- I tried to google around for a while before asking the list..

Best regards

Martin

#include <adolc/adolc.h>

#define BLASIZE 1024*32

adouble * bla = NULL;

adouble * makeBla(){return new adouble[BLASIZE];}

void setup()
{
  adouble m1 = 1.0; // no problems will occur, if this is commented out!
  bla = makeBla();
}

void cleanup()
{
  delete bla;
}

void fn(double *x) {
  bla[0] = x[0];//t3 +t1;
  bla[1] = x[1];//t3 - t2;
  for(int i = 2; i < BLASIZE; i++){bla[i] = bla[i-1] + bla[i-2];}
  return;
}


int main(void){
  double x[2] = {0,0};
  
  setup();
  
  for (int i = 0; i < 200; i++) {
    std::cout << i ;
    for(int j = 0; j < 100; j++) {
      x[0] = i * 0.001;
      x[1] = j * 0.001;
      fn(x);
      std::cout << "*";
    }
    std::cout << std::endl;
  }
  
  cleanup();
}




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/adol-c/attachments/20110405/8b0d72bd/attachment.html 


More information about the ADOL-C mailing list