/[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

revision 477 by jgs, Mon Jan 30 07:20:20 2006 UTC revision 798 by gross, Fri Aug 4 01:05:36 2006 UTC
# Line 1  Line 1 
1  /*  /*
2   ******************************************************************************   ************************************************************
3   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
4   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
5   *                                                                            *   *              http://www.access.edu.au                    *
6   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
7   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
8   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
9   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
10   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
11  */  */
12    
13  #include "Taipan.h"  #include "Taipan.h"
# Line 66  Taipan::~Taipan() { Line 64  Taipan::~Taipan() {
64    totalElements = -1;    totalElements = -1;
65  }  }
66    
67    void
68    Taipan::release_unused_arrays()
69    {
70      long len=0;
71      Taipan_MemTable *tab;
72      Taipan_MemTable *tab_next, *tab_prev=0;
73      tab = memTable_Root;
74      while (tab != 0) {
75          tab_next = tab->next;
76          if (tab->free) {
77            delete[] tab->array;
78            len += tab->dim * tab->N;
79            if (tab_prev != 0) {
80              tab_prev->next = tab->next;
81            } else {
82              memTable_Root = tab->next;
83            }
84            delete tab;
85            // increment count of arrays dealloced
86            statTable->deallocations++;
87          } else {
88            tab_prev = tab;
89          }
90          tab = tab_next;
91      }
92      totalElements -= len;
93      statTable->deallocated_elements += len;
94      cout << len*8./1048576 << " Mbytes unused memory has been released." << endl;
95    }
96    
97    
98  double*  double*
99  Taipan::new_array(int dim, int N) {  Taipan::new_array(int dim, int N) {
100    
# Line 306  Taipan::dump_stats() { Line 335  Taipan::dump_stats() {
335    float elMb=statTable->allocated_elements*8.0/1048576;    float elMb=statTable->allocated_elements*8.0/1048576;
336    float deelMb=statTable->deallocated_elements*8.0/1048576;    float deelMb=statTable->deallocated_elements*8.0/1048576;
337    float tszMb=statTable->max_tab_size*8.0/1048576;    float tszMb=statTable->max_tab_size*8.0/1048576;
338    #ifndef PASO_MPI
339    cout << "========== Mem Stats =============================" << endl;    cout << "======= escript Mem Stats ===========================" << endl;
340    cout << "Total Num requests:             " << statTable->requests << endl;    cout << "Total Num requests:             " << statTable->requests << endl;
341    cout << "Total Num releases:             " << statTable->frees << endl;    cout << "Total Num releases:             " << statTable->frees << endl;
342    cout << "Total Num allocated arrays:     " << statTable->allocations << endl;    cout << "Total Num allocated arrays:     " << statTable->allocations << endl;
# Line 318  Taipan::dump_stats() { Line 347  Taipan::dump_stats() {
347    cout << "Curr Num arrays:                " << num_arrays() << endl;    cout << "Curr Num arrays:                " << num_arrays() << endl;
348    cout << "Curr Num elements in buffer:    " << num_elements() << endl;    cout << "Curr Num elements in buffer:    " << num_elements() << endl;
349    cout << "==================================================" << endl;    cout << "==================================================" << endl;
350    #endif
351  }  }
352    
353  void  void

Legend:
Removed from v.477  
changed lines
  Added in v.798

  ViewVC Help
Powered by ViewVC 1.1.26