diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-08-26 02:55:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-08-26 02:55:00 +0000 |
commit | e15f981b761acb114010667880ef59fd508ee41a (patch) | |
tree | be57f518626e309b6a9b4219adfd1fcb4e89a7fe /Carpet/LoopControl/src/loopcontrol.h | |
parent | f6ff5079044289e1f748e800ce85e171fe766f5f (diff) |
LoopControl: Add automatic configuration based on simulated annealing
(Nice idea, but doesn't seem to work right. Maybe only the parameters
need to be chosen differently? But I rather think that a more
intelligent method is necessary.)
darcs-hash:20070826025505-dae7b-ed81bc28a4204d84776d28443be65a995c52699b.gz
Diffstat (limited to 'Carpet/LoopControl/src/loopcontrol.h')
-rw-r--r-- | Carpet/LoopControl/src/loopcontrol.h | 110 |
1 files changed, 35 insertions, 75 deletions
diff --git a/Carpet/LoopControl/src/loopcontrol.h b/Carpet/LoopControl/src/loopcontrol.h index 440e5ab26..43ac5784b 100644 --- a/Carpet/LoopControl/src/loopcontrol.h +++ b/Carpet/LoopControl/src/loopcontrol.h @@ -35,20 +35,25 @@ /* A topology */ -struct lc_topology_t { +typedef struct lc_topology_t { int ni, nj, nk; -}; +} lc_topology_t; /* A tiling specification */ -struct lc_tiling_t { +typedef struct lc_tiling_t { int npoints; -}; +} lc_tiling_t; + + + +/* For simulated annealing */ +typedef struct lc_auto_state_t lc_auto_state_t; /* Statistics for one control parameter set (thread topology and tiling specification) of one user parameter set of one loop */ -struct lc_stattime_t { +typedef struct lc_stattime_t { struct lc_stattime_t * next; /* Keys */ @@ -64,11 +69,11 @@ struct lc_stattime_t { double time_count; /* number of calls and threads */ double time_setup_sum, time_setup_sum2; /* time spent setting up loops */ double time_calc_sum, time_calc_sum2; /* time spent iterating */ -}; +} lc_stattime_t; /* Statistics for one user parameter set (number of threads and number of iterations) of one loop */ -struct lc_statset_t { +typedef struct lc_statset_t { struct lc_statset_t * next; /* Keys */ @@ -79,35 +84,38 @@ struct lc_statset_t { /* Data */ /* Thread topologies */ - struct lc_topology_t * restrict topologies; + lc_topology_t * restrict topologies; int ntopologies; /* Tiling specifications */ - struct lc_tiling_t * restrict tilings[3]; + lc_tiling_t * restrict tilings[3]; int ntilings[3]; - struct lc_stattime_t * stattime_list; -}; + /* Simulated annealing state */ + lc_auto_state_t * auto_state; + + lc_stattime_t * stattime_list; +} lc_statset_t; /* Statistics for one loop (one source code location) */ -struct lc_statmap_t { +typedef struct lc_statmap_t { struct lc_statmap_t * next; /* for linked list */ /* Name */ char const * restrict name; - struct lc_statset_t * statset_list; -}; + lc_statset_t * statset_list; +} lc_statmap_t; /* Linked list of all loop statistics structures */ -extern struct lc_statmap_t * lc_statmap_list; +extern lc_statmap_t * lc_statmap_list; -struct lc_control_t { - struct lc_statmap_t * restrict statmap; - struct lc_statset_t * restrict statset; - struct lc_stattime_t * restrict stattime; +typedef struct lc_control_t { + lc_statmap_t * restrict statmap; + lc_statset_t * restrict statset; + lc_stattime_t * restrict stattime; /* Copy of arguments (useful for debugging) */ int imin, jmin, kmin; @@ -130,7 +138,7 @@ struct lc_control_t { /* Timing statistics */ double time_setup_begin, time_calc_begin; -}; +} lc_control_t; @@ -151,24 +159,24 @@ lc_max (int const i, int const j) void -lc_statmap_init (struct lc_statmap_t * restrict ls, +lc_statmap_init (lc_statmap_t * restrict ls, char const * restrict name); void -lc_control_init (struct lc_control_t * restrict lc, - struct lc_statmap_t * restrict lm, +lc_control_init (lc_control_t * restrict lc, + lc_statmap_t * restrict lm, int imin, int jmin, int kmin, int imax, int jmax, int kmax, int ilsh, int jlsh, int klsh); void -lc_control_finish (struct lc_control_t * restrict lc); +lc_control_finish (lc_control_t * restrict lc); #define LC_LOOP3(name, i,j,k, imin,jmin,kmin, imax,jmax,kmax, ilsh,jlsh,klsh) \ do { \ - static struct lc_statmap_t lc_lm; \ + static lc_statmap_t lc_lm; \ static int lc_initialised = 0; \ if (! lc_initialised) { \ _Pragma ("omp single") { \ @@ -179,7 +187,7 @@ lc_control_finish (struct lc_control_t * restrict lc); lc_initialised = 1; \ } \ } \ - struct lc_control_t lc_lc; \ + lc_control_t lc_lc; \ lc_control_init (& lc_lc, & lc_lm, \ imin,jmin,kmin, imax,jmax,kmax, ilsh,jlsh,klsh); \ \ @@ -224,55 +232,7 @@ lc_printstats (CCTK_ARGUMENTS); #ifdef FCODE - -#define LC_DECLARE3(name, i,j,k) &&\ -type (lc_statmap_t), save :: name/**/_lm &&\ -logical, save :: name/**/_initialised = .false. &&\ -type (lc_control_t) :: name/**/_lc &&\ -integer :: name/**/_ii, name/**/_jj, name/**/_kk &&\ -integer :: name/**/_imax, name/**/_jmax, name/**/_kmax &&\ -integer :: i, j, k - -#define LC_PRIVATE3(name) \ -name/**/_lc, \ -name/**/_imax, name/**/_jmax, name/**/_kmax - -#define LC_LOOP3(name, i,j,k, imin,jmin,kmin, imax,jmax,kmax, ilsh,jlsh,klsh) &&\ -if (.not. name/**/_initialised) then &&\ -!$omp single &&\ - call lc_statmap_init (name/**/_lm, "name") &&\ -!$omp end single &&\ -!$omp single &&\ - /* Set this flag only after initialising */ &&\ - name/**/_initialised = .true. &&\ -!$omp end single &&\ -end if &&\ -call lc_control_init (name/**/_lc, name/**/_lm, imin,jmin,kmin, imax,jmax,kmax, ilsh,jlsh,klsh) &&\ - &&\ -/* Coarse loop */ &&\ -do name/**/_kk = name/**/_lc%kkmin + 1, name/**/_lc%kkmax, name/**/_lc%kkstep &&\ - name/**/_kmax = min (name/**/_kk - 1 + name/**/_lc%kkstep, name/**/_lc%kkmax) &&\ - do name/**/_jj = name/**/_lc%jjmin + 1, name/**/_lc%jjmax, name/**/_lc%jjstep &&\ - name/**/_jmax = min (name/**/_jj - 1 + name/**/_lc%jjstep, name/**/_lc%jjmax) &&\ - do name/**/_ii = name/**/_lc%iimin + 1, name/**/_lc%iimax, name/**/_lc%iistep &&\ - name/**/_imax = min (name/**/_ii - 1 + name/**/_lc%iistep, name/**/_lc%iimax) &&\ - &&\ - /* Fine loop */ &&\ - do k = name/**/_kk, name/**/_kmax &&\ - do j = name/**/_jj, name/**/_jmax &&\ - do i = name/**/_ii, name/**/_imax - -#define LC_ENDLOOP3(name) &&\ - end do &&\ - end do &&\ - end do &&\ - &&\ - end do &&\ - end do &&\ -end do &&\ - &&\ -call lc_control_finish (name/**/_lc) - +# include "loopcontrol_fortran.h" #endif #endif /* ifndef LC_LOOPCONTROL_H */ |