/[escript]/trunk/escript/src/Taipan.cpp
ViewVC logotype

Diff of /trunk/escript/src/Taipan.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/escript/src/Data/Taipan.cpp revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/escript/src/Taipan.cpp revision 1559 by ksteube, Wed May 21 04:27:15 2008 UTC
# Line 1  Line 1 
 /*  
  ******************************************************************************  
  *                                                                            *  
  *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  
  *                                                                            *  
  * This software is the property of ACcESS. No part of this code              *  
  * may be copied in any form or by any means without the expressed written    *  
  * consent of ACcESS.  Copying, use or modification of this software          *  
  * by any unauthorised person is illegal unless that person has a software    *  
  * license agreement with ACcESS.                                             *  
  *                                                                            *  
  ******************************************************************************  
 */  
1    
2  #include "escript/Data/Taipan.h"  /* $Id$ */
3    
4    /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16    #include "Taipan.h"
17    
18  #include <iostream>  #include <iostream>
19  #include <cassert>  #include <cassert>
# Line 66  Taipan::~Taipan() { Line 67  Taipan::~Taipan() {
67    totalElements = -1;    totalElements = -1;
68  }  }
69    
70    void
71    Taipan::release_unused_arrays()
72    {
73      long len=0;
74      Taipan_MemTable *tab;
75      Taipan_MemTable *tab_next, *tab_prev=0;
76      tab = memTable_Root;
77      while (tab != 0) {
78          tab_next = tab->next;
79          if (tab->free) {
80            delete[] tab->array;
81            len += tab->dim * tab->N;
82            if (tab_prev != 0) {
83              tab_prev->next = tab->next;
84            } else {
85              memTable_Root = tab->next;
86            }
87            delete tab;
88            // increment count of arrays dealloced
89            statTable->deallocations++;
90          } else {
91            tab_prev = tab;
92          }
93          tab = tab_next;
94      }
95      totalElements -= len;
96      statTable->deallocated_elements += len;
97      cout << len*8./1048576 << " Mbytes unused memory has been released." << endl;
98    }
99    
100    
101  double*  double*
102  Taipan::new_array(int dim, int N) {  Taipan::new_array(int dim, int N) {
103    
# Line 306  Taipan::dump_stats() { Line 338  Taipan::dump_stats() {
338    float elMb=statTable->allocated_elements*8.0/1048576;    float elMb=statTable->allocated_elements*8.0/1048576;
339    float deelMb=statTable->deallocated_elements*8.0/1048576;    float deelMb=statTable->deallocated_elements*8.0/1048576;
340    float tszMb=statTable->max_tab_size*8.0/1048576;    float tszMb=statTable->max_tab_size*8.0/1048576;
341    #ifdef TAIPAN_STATS
342    cout << "========== Mem Stats =============================" << endl;    cout << "======= escript Mem Stats ===========================" << endl;
343    cout << "Total Num requests:             " << statTable->requests << endl;    cout << "Total Num requests:             " << statTable->requests << endl;
344    cout << "Total Num releases:             " << statTable->frees << endl;    cout << "Total Num releases:             " << statTable->frees << endl;
345    cout << "Total Num allocated arrays:     " << statTable->allocations << endl;    cout << "Total Num allocated arrays:     " << statTable->allocations << endl;
# Line 318  Taipan::dump_stats() { Line 350  Taipan::dump_stats() {
350    cout << "Curr Num arrays:                " << num_arrays() << endl;    cout << "Curr Num arrays:                " << num_arrays() << endl;
351    cout << "Curr Num elements in buffer:    " << num_elements() << endl;    cout << "Curr Num elements in buffer:    " << num_elements() << endl;
352    cout << "==================================================" << endl;    cout << "==================================================" << endl;
353    #endif
354  }  }
355    
356  void  void

Legend:
Removed from v.155  
changed lines
  Added in v.1559

  ViewVC Help
Powered by ViewVC 1.1.26