Patch: Doof2d: Eliminate Duplicate Computations

Jeffrey Oldham oldham at codesourcery.com
Fri Oct 12 20:50:50 UTC 2001


2001-10-12  Jeffrey D. Oldham  <oldham at codesourcery.com>

        This patch reduces duplicate computation in the Doof2d benchmarks.
        Both initialize() and run() set the initial conditions.  In
        consultations with Stephen Smith, we have the untimed initialize()
        ensure that all the allocated memory pages are actually created
        and have run() set up the initial conditions.

        * Doof2d.h (Doof2dBase::initialize): Replace initialize() with
        statements to ensure all memory pages are actually created.
        (Doof2dBase::setInitialConditions): Removed in favor of code in
        initialize().
        * Doof2dInC.h (Doof2dInC::initialize) and
        (Doof2dInC::setInitialConditions): Likewise.
        (Doof2dCoefsInC::initialize) and
        (Doof2dCoefsInC::setInitialConditions): Likewise.

Tested on       sequential Linux using g++3.1 by running Doof2d
Approved by     Stephen Smith
Applied to      mainline

Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: Doof2d.h
===================================================================
RCS file: /home/pooma/Repository/r2/benchmarks/Doof2d/Doof2d.h,v
retrieving revision 1.1
diff -c -p -r1.1 Doof2d.h
*** Doof2d.h	2001/09/28 03:41:36	1.1
--- Doof2d.h	2001/10/12 18:52:10
*************** public:
*** 285,293 ****
      I = Interval<1>(2,n_m-1);
      J = Interval<1>(2,n_m-1);
  
!     // Intialize Array element values.
!     
!     setInitialConditions();
    }
  
    // Return value for checking result of benchmark run.
--- 285,295 ----
      I = Interval<1>(2,n_m-1);
      J = Interval<1>(2,n_m-1);
  
!     // Ensure that all memory is paged in.
! 
!     a_m = 0.0;
!     b_m = 0.0;
!     Pooma::blockAndEvaluate();
    }
  
    // Return value for checking result of benchmark run.
*************** protected:
*** 316,332 ****
    
    Interval<1> I, J;
  
- private:
- 
-   void setInitialConditions()
-   {
-     // Initialize arrays.
- 
-     a_m = 0.0;
-     b_m = 0.0;
-     
-     Pooma::blockAndEvaluate();
-   }
  };
  
  
--- 318,323 ----
Index: Doof2dInC.h
===================================================================
RCS file: /home/pooma/Repository/r2/benchmarks/Doof2d/Doof2dInC.h,v
retrieving revision 1.23
diff -c -p -r1.23 Doof2dInC.h
*** Doof2dInC.h	2001/09/28 03:41:36	1.23
--- Doof2dInC.h	2001/10/12 18:52:10
*************** public:
*** 93,100 ****
      // Save problem size.
      n_m = n;
  
!     // initialize arrays
!     setInitialConditions();
    }
  
    void run() {
--- 93,106 ----
      // Save problem size.
      n_m = n;
  
!     // Ensure that all memory is paged in.
! 
!     for (int j = 0; j < n_m; j++) {
!       for (int i = 0; i < n_m; i++) {
! 	a_m[i + n_m * j] = 0.0;
!         b_m[i + n_m * j] = 0.0;
!       }
!     }
    }
  
    void run() {
*************** public:
*** 124,141 ****
  
  private:
  
-   void setInitialConditions() 
-   {
-     // initialize the arrays.
-     for (int j = 0; j < n_m; j++) {
-       for (int i = 0; i < n_m; i++) {
- 	a_m[i + n_m * j] = 0.0;
-         b_m[i + n_m * j] = 0.0;
-         b_m[n_m / 2 - 1 + n_m * (n_m / 2 - 1)] = 1000.0;
-       }
-     }
-   }
- 
    // Data Arrays.
  
    double *a_m, *b_m;
--- 130,135 ----
*************** public:
*** 191,198 ****
      // Save problem size.
      n_m = n;
  
!     // Initialize the arrays.
!     setInitialConditions();
    }
  
    void run() {
--- 185,198 ----
      // Save problem size.
      n_m = n;
  
!     // Ensure that all memory is paged in.
! 
!     for (int j = 0; j < n_m; j++) {
!       for (int i = 0; i < n_m; i++) {
! 	a_m[i + n_m * j] = 0.0;
!         b_m[i + n_m * j] = 0.0;
!       }
!     }
    }
  
    void run() {
*************** public:
*** 220,237 ****
    double opCount() const { return ( 180 * ((double)n_m - 2) * ((double)n_m - 2) ); }
  
  private:
- 
-   void setInitialConditions() 
-   {
-     // initialize the arrays.
-     for (int j = 0; j < n_m; j++) {
-       for (int i = 0; i < n_m; i++) {
- 	a_m[i + n_m * j] = 0.0;
-         b_m[i + n_m * j] = 0.0;
-       }
-     }
-     b_m[n_m / 2 - 1 + n_m * (n_m / 2 - 1)] = 1000.0;
-   }
  
    // Data Arrays.
  
--- 220,225 ----


More information about the pooma-dev mailing list