Threaded one more loop and added notations about future loops to thread.

This commit is contained in:
falgout 2011-01-28 23:05:07 +00:00
parent c220065050
commit 462be77963
2 changed files with 42 additions and 69 deletions

View File

@ -10,9 +10,6 @@
* $Revision$ * $Revision$
***********************************************************************EHEADER*/ ***********************************************************************EHEADER*/
/****************************************************************************** /******************************************************************************
* *
* HYPRE_SStructGraph interface * HYPRE_SStructGraph interface
@ -83,10 +80,9 @@ HYPRE_SStructGraphCreate( MPI_Comm comm,
hypre_SStructGraphObjectType(graph) = HYPRE_SSTRUCT; hypre_SStructGraphObjectType(graph) = HYPRE_SSTRUCT;
hypre_SStructGraphEntries(graph) = NULL; hypre_SStructGraphEntries(graph) = NULL;
hypre_SStructNGraphEntries(graph) =0; hypre_SStructNGraphEntries(graph) = 0;
hypre_SStructAGraphEntries(graph) =0; hypre_SStructAGraphEntries(graph) = 0;
*graph_ptr = graph; *graph_ptr = graph;
return hypre_error_flag; return hypre_error_flag;
@ -148,6 +144,7 @@ HYPRE_SStructGraphDestroy( HYPRE_SStructGraph graph )
hypre_TFree(fem_sparse_i); hypre_TFree(fem_sparse_i);
hypre_TFree(fem_sparse_j); hypre_TFree(fem_sparse_j);
hypre_TFree(fem_entries); hypre_TFree(fem_entries);
/* RDF: THREAD? */
for (i = 0; i < nUventries; i++) for (i = 0; i < nUventries; i++)
{ {
Uventry = Uventries[iUventries[i]]; Uventry = Uventries[iUventries[i]];
@ -190,8 +187,7 @@ HYPRE_SStructGraphSetStencil( HYPRE_SStructGraph graph,
HYPRE_Int var, HYPRE_Int var,
HYPRE_SStructStencil stencil ) HYPRE_SStructStencil stencil )
{ {
hypre_SStructStencilRef(stencil, hypre_SStructStencilRef(stencil, &hypre_SStructGraphStencil(graph, part, var));
&hypre_SStructGraphStencil(graph, part, var));
return hypre_error_flag; return hypre_error_flag;
} }
@ -241,7 +237,6 @@ HYPRE_SStructGraphSetFEMSparsity( HYPRE_SStructGraph graph,
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
* THIS IS FOR A NON-OVERLAPPING GRID GRAPH. * THIS IS FOR A NON-OVERLAPPING GRID GRAPH.
* *
*
* Now we just keep track of calls to this function and do all the "work" * Now we just keep track of calls to this function and do all the "work"
* in the assemble. * in the assemble.
*--------------------------------------------------------------------------*/ *--------------------------------------------------------------------------*/
@ -255,12 +250,10 @@ HYPRE_SStructGraphAddEntries( HYPRE_SStructGraph graph,
HYPRE_Int *to_index, HYPRE_Int *to_index,
HYPRE_Int to_var ) HYPRE_Int to_var )
{ {
hypre_SStructGrid *grid = hypre_SStructGraphGrid(graph);
HYPRE_Int ndim = hypre_SStructGridNDim(grid);
hypre_SStructGraphEntry **entries = hypre_SStructGraphEntries(graph);
hypre_SStructGrid *grid = hypre_SStructGraphGrid(graph);
HYPRE_Int ndim = hypre_SStructGridNDim(grid);
hypre_SStructGraphEntry **entries = hypre_SStructGraphEntries(graph);
hypre_SStructGraphEntry *new_entry; hypre_SStructGraphEntry *new_entry;
HYPRE_Int n_entries = hypre_SStructNGraphEntries(graph); HYPRE_Int n_entries = hypre_SStructNGraphEntries(graph);
@ -295,7 +288,8 @@ HYPRE_SStructGraphAddEntries( HYPRE_SStructGraph graph,
hypre_SStructGraphEntryToVar(new_entry) = to_var; hypre_SStructGraphEntryToVar(new_entry) = to_var;
hypre_CopyToCleanIndex(index, ndim, hypre_SStructGraphEntryIndex(new_entry)); hypre_CopyToCleanIndex(index, ndim, hypre_SStructGraphEntryIndex(new_entry));
hypre_CopyToCleanIndex(to_index, ndim, hypre_SStructGraphEntryToIndex(new_entry)); hypre_CopyToCleanIndex(
to_index, ndim, hypre_SStructGraphEntryToIndex(new_entry));
entries[n_entries] = new_entry; entries[n_entries] = new_entry;
@ -303,7 +297,6 @@ HYPRE_SStructGraphAddEntries( HYPRE_SStructGraph graph,
n_entries++; n_entries++;
hypre_SStructNGraphEntries(graph) = n_entries; hypre_SStructNGraphEntries(graph) = n_entries;
return hypre_error_flag; return hypre_error_flag;
} }
@ -370,7 +363,6 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
HYPRE_Int ndim = hypre_SStructGridNDim(grid); HYPRE_Int ndim = hypre_SStructGridNDim(grid);
hypre_SStructUEntry *Uentries; hypre_SStructUEntry *Uentries;
#if HYPRE_NO_GLOBAL_PARTITION #if HYPRE_NO_GLOBAL_PARTITION
/* may need to re-do box managers for the AP*/ /* may need to re-do box managers for the AP*/
@ -390,16 +382,17 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
hypre_Box *bbox, *new_box; hypre_Box *bbox, *new_box;
hypre_StructGrid *sgrid; hypre_StructGrid *sgrid;
HYPRE_Int *num_ghost; HYPRE_Int *num_ghost;
/*--------------------------------------------------------- /*---------------------------------------------------------
* If AP, then may need to redo the box managers * If AP, then may need to redo the box managers
*---------------------------------------------------------*/ *---------------------------------------------------------*/
new_box = hypre_BoxCreate(); new_box = hypre_BoxCreate();
/* if any processor has added entries, then all /* if any processor has added entries, then all need to participate */
need to participate */
hypre_MPI_Allreduce(&n_add_entries, &global_n_add_entries, 1, HYPRE_MPI_INT, hypre_MPI_SUM, comm); hypre_MPI_Allreduce(&n_add_entries, &global_n_add_entries,
1, HYPRE_MPI_INT, hypre_MPI_SUM, comm);
if (global_n_add_entries > 0 ) if (global_n_add_entries > 0 )
{ {
@ -426,12 +419,9 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
hypre_StructGridComm(sgrid), hypre_StructGridComm(sgrid),
&new_managers[part][var]); &new_managers[part][var]);
/* need to set the num ghost for new manager also */ /* need to set the num ghost for new manager also */
num_ghost = hypre_StructGridNumGhost(sgrid); num_ghost = hypre_StructGridNumGhost(sgrid);
hypre_BoxManSetNumGhost(new_managers[part][var], num_ghost); hypre_BoxManSetNumGhost(new_managers[part][var], num_ghost);
} }
} /* end loop over parts */ } /* end loop over parts */
@ -456,9 +446,7 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
if (hypre_IndexInBoxP(index,bbox) != 0) if (hypre_IndexInBoxP(index,bbox) != 0)
{ {
hypre_BoxManGatherEntries(new_boxman,index, index);
hypre_BoxManGatherEntries( new_boxman,
index, index);
} }
/* now repeat the check for to_part, to_var, to_index */ /* now repeat the check for to_part, to_var, to_index */
@ -472,16 +460,13 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
if (hypre_IndexInBoxP(to_index,bbox) != 0) if (hypre_IndexInBoxP(to_index,bbox) != 0)
{ {
hypre_BoxManGatherEntries( new_boxman, hypre_BoxManGatherEntries(new_boxman,to_index, to_index);
to_index, to_index);
} }
} }
/* Now go through the managers and if gather has been called (on /* Now go through the managers and if gather has been called (on any
any processor) then populate the new manager with the entries processor) then populate the new manager with the entries from the old
from the old manager and then assemble and delete the old manager and then assemble and delete the old manager. */
manager. */
for (part = 0; part < nparts; part++) for (part = 0; part < nparts; part++)
{ {
pgrid = hypre_SStructGridPGrid(grid, part); pgrid = hypre_SStructGridPGrid(grid, part);
@ -490,9 +475,7 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
for (var = 0; var < nvars; var++) for (var = 0; var < nvars; var++)
{ {
new_boxman = new_managers[part][var]; new_boxman = new_managers[part][var];
hypre_BoxManGetGlobalIsGatherCalled( new_boxman, hypre_BoxManGetGlobalIsGatherCalled(new_boxman, comm, &is_gather);
comm,
&is_gather );
if (is_gather) if (is_gather)
{ {
/* Gather has been called on at least 1 proc - copy /* Gather has been called on at least 1 proc - copy
@ -500,12 +483,10 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
orig_boxman = managers[part][var]; orig_boxman = managers[part][var];
hypre_BoxManGetAllEntries(orig_boxman , hypre_BoxManGetAllEntries(orig_boxman, &num_entries, &all_entries);
&num_entries, &all_entries);
for (j=0; j< num_entries; j++) for (j=0; j< num_entries; j++)
{ {
entry = &all_entries[j]; entry = &all_entries[j];
hypre_BoxManEntryGetInfo(entry, &info); hypre_BoxManEntryGetInfo(entry, &info);
@ -516,23 +497,20 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
hypre_BoxManEntryProc(entry), hypre_BoxManEntryProc(entry),
hypre_BoxManEntryId(entry), hypre_BoxManEntryId(entry),
info); info);
} }
/* call assemble for new boxmanager*/ /* call assemble for new boxmanager*/
hypre_BoxManAssemble(new_boxman); hypre_BoxManAssemble(new_boxman);
/* TEMP for testing /* TEMP for testing
if (hypre_BoxManNEntries(new_boxman) != num_entries) if (hypre_BoxManNEntries(new_boxman) != num_entries)
{ {
hypre_MPI_Comm_rank(comm, &myproc); hypre_MPI_Comm_rank(comm, &myproc);
hypre_printf("myid = %d, new_entries = %d, old entries = %d\n", myproc, hypre_BoxManNEntries(new_boxman), num_entries); hypre_printf("myid = %d, new_entries = %d, old entries = %d\n", myproc, hypre_BoxManNEntries(new_boxman), num_entries);
} */ } */
/* destroy old manager */ /* destroy old manager */
hypre_BoxManDestroy (managers[part][var]); hypre_BoxManDestroy (managers[part][var]);
} }
else /* no gather called */ else /* no gather called */
{ {
@ -550,20 +528,17 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
/* assign the new ones */ /* assign the new ones */
hypre_SStructGridBoxManagers(grid) = new_managers; hypre_SStructGridBoxManagers(grid) = new_managers;
} }
/* clean up */ /* clean up */
hypre_BoxDestroy(new_box); hypre_BoxDestroy(new_box);
/* end of AP stuff */ /* end of AP stuff */
#endif #endif
hypre_MPI_Comm_size(comm, &nprocs); hypre_MPI_Comm_size(comm, &nprocs);
hypre_MPI_Comm_rank(comm, &myproc); hypre_MPI_Comm_rank(comm, &myproc);
/*--------------------------------------------------------- /*---------------------------------------------------------
* First we do the work that was previously in the AddEntries: * First we do the work that was previously in the AddEntries:
* set up the UVEntry and iUventries * set up the UVEntry and iUventries
@ -638,7 +613,6 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
hypre_SStructUVEntryNUEntries(Uventry) = nUentries; hypre_SStructUVEntryNUEntries(Uventry) = nUentries;
hypre_SStructUVEntryUEntries(Uventry) = Uentries; hypre_SStructUVEntryUEntries(Uventry) = Uentries;
i = nUentries - 1; i = nUentries - 1;
hypre_SStructUVEntryToPart(Uventry, i) = to_part; hypre_SStructUVEntryToPart(Uventry, i) = to_part;
hypre_CopyToCleanIndex(to_index, ndim, hypre_CopyToCleanIndex(to_index, ndim,
@ -663,19 +637,14 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
hypre_SStructGraphTotUEntries(graph) ++; hypre_SStructGraphTotUEntries(graph) ++;
/*free each add entry after copying */ /*free each add entry after copying */
hypre_TFree(new_entry); hypre_TFree(new_entry);
}/* end of loop through add entries */ }/* end of loop through add entries */
/* free the storage for the add entires */ /* free the storage for the add entires */
hypre_TFree(add_entries); hypre_TFree(add_entries);
/*--------------------------------------------------------- /*---------------------------------------------------------
* Set up the FEM stencil information * Set up the FEM stencil information
*---------------------------------------------------------*/ *---------------------------------------------------------*/
@ -822,8 +791,8 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
* Compute non-stencil column numbers (if possible), and * Compute non-stencil column numbers (if possible), and
* start building requests for needed off-process info. * start building requests for needed off-process info.
*---------------------------------------------------------*/ *---------------------------------------------------------*/
/* RDF: THREAD? */
for (i = 0; i < nUventries; i++) for (i = 0; i < nUventries; i++)
{ {
Uventry = Uventries[iUventries[i]]; Uventry = Uventries[iUventries[i]];
@ -852,14 +821,13 @@ HYPRE_SStructGraphAssemble( HYPRE_SStructGraph graph )
} }
else else
{ {
/* This should not happen (TO DO: take out print statement)*/ /* This should not happen (TO DO: take out print statement) */
hypre_printf("Error in HYPRE_SStructGraphAssemble, my id = %d\n", myproc); hypre_printf("Error in HYPRE_SStructGraphAssemble, my id = %d\n",
myproc);
} }
} }
} }
return hypre_error_flag; return hypre_error_flag;
} }

View File

@ -10,7 +10,6 @@
* $Revision$ * $Revision$
***********************************************************************EHEADER*/ ***********************************************************************EHEADER*/
/****************************************************************************** /******************************************************************************
* *
* Member functions for hypre_SStructPMatrix class. * Member functions for hypre_SStructPMatrix class.
@ -120,9 +119,8 @@ hypre_SStructPMatrixCreate( MPI_Comm comm,
{ {
if (new_sizes[vj]) if (new_sizes[vj])
{ {
sstencils[vi][vj] = hypre_StructStencilCreate(new_dim, sstencils[vi][vj] =
new_sizes[vj], hypre_StructStencilCreate(new_dim, new_sizes[vj], new_shapes[vj]);
new_shapes[vj]);
} }
size = hypre_max(size, new_sizes[vj]); size = hypre_max(size, new_sizes[vj]);
} }
@ -771,6 +769,7 @@ hypre_SStructUMatrixInitialize( hypre_SStructMatrix *matrix )
/* GEC0902 essentially for each UVentry we figure out how many extra columns /* GEC0902 essentially for each UVentry we figure out how many extra columns
* we need to add to the rowsizes */ * we need to add to the rowsizes */
/* RDF: THREAD? */
for (entry = 0; entry < nUventries; entry++) for (entry = 0; entry < nUventries; entry++)
{ {
m = iUventries[entry]; m = iUventries[entry];
@ -970,7 +969,7 @@ hypre_SStructUMatrixSetBoxValues( hypre_SStructMatrix *matrix,
HYPRE_Int row_base, col_base, val_base; HYPRE_Int row_base, col_base, val_base;
HYPRE_Int e, entry, ii, jj, i, j, k; HYPRE_Int e, entry, ii, jj, i, j, k;
/* GEC1002 the matrix type */ /* GEC1002 the matrix type */
HYPRE_Int matrix_type = hypre_SStructMatrixObjectType(matrix); HYPRE_Int matrix_type = hypre_SStructMatrixObjectType(matrix);
box = hypre_BoxCreate(); box = hypre_BoxCreate();
@ -988,6 +987,8 @@ hypre_SStructUMatrixSetBoxValues( hypre_SStructMatrix *matrix,
hypre_BoxSetExtents(box, ilower, iupper); hypre_BoxSetExtents(box, ilower, iupper);
nrows = hypre_BoxVolume(box)*nentries; nrows = hypre_BoxVolume(box)*nentries;
ncols = hypre_CTAlloc(HYPRE_Int, nrows); ncols = hypre_CTAlloc(HYPRE_Int, nrows);
#define HYPRE_SMP_PRIVATE i
#include "hypre_smp_forloop.h"
for (i = 0; i < nrows; i++) for (i = 0; i < nrows; i++)
{ {
ncols[i] = 1; ncols[i] = 1;
@ -1070,7 +1071,8 @@ hypre_SStructUMatrixSetBoxValues( hypre_SStructMatrix *matrix,
val_base = e + (hypre_IndexX(index) + val_base = e + (hypre_IndexX(index) +
hypre_IndexY(index)*sy + hypre_IndexY(index)*sy +
hypre_IndexZ(index)*sz) * nentries; hypre_IndexZ(index)*sz) * nentries;
/* RDF: THREAD */
for (k = 0; k < hypre_BoxSizeZ(int_box); k++) for (k = 0; k < hypre_BoxSizeZ(int_box); k++)
{ {
for (j = 0; j < hypre_BoxSizeY(int_box); j++) for (j = 0; j < hypre_BoxSizeY(int_box); j++)
@ -1125,7 +1127,7 @@ hypre_SStructUMatrixSetBoxValues( hypre_SStructMatrix *matrix,
hypre_BoxDestroy(to_box); hypre_BoxDestroy(to_box);
hypre_BoxDestroy(map_box); hypre_BoxDestroy(map_box);
hypre_BoxDestroy(int_box); hypre_BoxDestroy(int_box);
} }
/*------------------------------------------ /*------------------------------------------
* non-stencil entries * non-stencil entries
@ -1136,6 +1138,7 @@ hypre_SStructUMatrixSetBoxValues( hypre_SStructMatrix *matrix,
hypre_CopyIndex(ilower, hypre_BoxIMin(box)); hypre_CopyIndex(ilower, hypre_BoxIMin(box));
hypre_CopyIndex(iupper, hypre_BoxIMax(box)); hypre_CopyIndex(iupper, hypre_BoxIMax(box));
/* RDF: THREAD (Check safety on UMatrixSetValues call) */
for (k = hypre_BoxIMinZ(box); k <= hypre_BoxIMaxZ(box); k++) for (k = hypre_BoxIMinZ(box); k <= hypre_BoxIMaxZ(box); k++)
{ {
for (j = hypre_BoxIMinY(box); j <= hypre_BoxIMaxY(box); j++) for (j = hypre_BoxIMinY(box); j <= hypre_BoxIMaxY(box); j++)
@ -1509,6 +1512,7 @@ hypre_SStructMatrixSetInterPartValues( HYPRE_SStructMatrix matrix,
{ {
/* set or add */ /* set or add */
/* RDF: THREAD */
/* copy values into tvalues */ /* copy values into tvalues */
tvi = 0; tvi = 0;
for (k = 0; k < inz; k++) for (k = 0; k < inz; k++)
@ -1542,6 +1546,7 @@ hypre_SStructMatrixSetInterPartValues( HYPRE_SStructMatrix matrix,
matrix, part, hypre_BoxIMin(ibox1), hypre_BoxIMax(ibox1), matrix, part, hypre_BoxIMin(ibox1), hypre_BoxIMax(ibox1),
var, 1, &entry, tvalues, action); var, 1, &entry, tvalues, action);
/* RDF: THREAD */
/* copy tvalues into values */ /* copy tvalues into values */
tvi = 0; tvi = 0;
for (k = 0; k < inz; k++) for (k = 0; k < inz; k++)