Skip to content

Commit

Permalink
Modify smf_checkmem_map.c for new memory usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarsden committed Oct 28, 2013
1 parent 1e26781 commit 8229fb3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion applications/smurf/libsmf/smf.h.source
Expand Up @@ -716,7 +716,7 @@ void smf_checkmem_dimm( dim_t maxlen, inst_t instrument, int nrelated,
AstKeyMap *keymap, size_t available, dim_t maxfilelen,
size_t *necessary, int *status );

void smf_checkmem_map( const int lbnd[2], const int ubnd[2], int rebin,
void smf_checkmem_map( const int lbnd[2], const int ubnd[2], int rebin, int nw,
size_t available, size_t *necessary, int *status );

double smf_chunkweight( smfData *data, AstKeyMap *keymap, int contchunk,
Expand Down
14 changes: 12 additions & 2 deletions applications/smurf/libsmf/smf_checkmem_map.c
Expand Up @@ -14,7 +14,8 @@
* Invocation:
* smf_checkmem_map( const int lbnd[2], const int ubnd[2], int rebin,
* size_t available, size_t *necessary, int *status );
* int nw, size_t available, size_t *necessary,
* int *status );
* Arguments:
* lbnd = const int[2] (Given)
Expand All @@ -23,6 +24,8 @@
* 2-element array indices for upper bounds of the output map
* rebin = int (Given)
* If set calculate memory for method=rebin. Otherwise method=iterate.
* nw = int (Given)
* Number of worker threads, since iteratemap uses nw temp maps
* available = size_t (Given)
* Maximum memory in bytes that the mapped arrays may occupy
* necessary = size_t * (Returned)
Expand All @@ -38,6 +41,7 @@
* Authors:
* Edward Chapin (UBC)
* Gaelen Marsden (AGM, UBC)
* {enter_new_authors_here}
* History:
Expand All @@ -49,6 +53,8 @@
* Extra space required for mapweight^2 array in iteratemap
* 2010-09-20 (TIMJ):
* We are using MiB not Mb
* 2013-10-24 (AGM):
* smf_iteratemap uses nw maps for temporary calculations
* {enter_further_changes_here}
* Notes:
Expand Down Expand Up @@ -94,7 +100,7 @@

#define FUNC_NAME "smf_checkmem_map"

void smf_checkmem_map( const int lbnd[], const int ubnd[], int rebin,
void smf_checkmem_map( const int lbnd[], const int ubnd[], int rebin, int nw,
size_t available, size_t *necessary, int *status ) {

/* Local Variables */
Expand Down Expand Up @@ -152,6 +158,10 @@ void smf_checkmem_map( const int lbnd[], const int ubnd[], int rebin,

/* smf_iteratemap also uses a local buffer to accumulate weights^2 */
total += sizeof(double)*mapsize;

/* add (nw - 1) maps for threaded calculations
uses 4 doubles (map, mapvar, weight, weightsq) and 1 int (hitsmap) */
total += 4*(nw-1)*sizeof(double)*mapsize + (nw-1)*sizeof(int)*mapsize;
}

/* Set bad status if too big */
Expand Down
2 changes: 1 addition & 1 deletion applications/smurf/libsmf/smf_iteratemap.c
Expand Up @@ -1159,7 +1159,7 @@ void smf_iteratemap( ThrWorkForce *wf, const Grp *igrp, const Grp *iterrootgrp,

/* First check memory for the map and subtract off total memory to
see what is available for model components. */
smf_checkmem_map( lbnd_out, ubnd_out, 0, maxmem, &mapmem, status );
smf_checkmem_map( lbnd_out, ubnd_out, 0, nw, maxmem, &mapmem, status );
maxdimm = maxmem-mapmem;

/* Then the iterative components that are proportional to time */
Expand Down

0 comments on commit 8229fb3

Please sign in to comment.