Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IJ assembly memory #1099

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions src/IJ_mv/HYPRE_IJMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,90 @@ HYPRE_IJMatrixSetMaxOffProcElmts( HYPRE_IJMatrix matrix,
return hypre_error_flag;
}

/*--------------------------------------------------------------------------
*--------------------------------------------------------------------------*/

HYPRE_Int
HYPRE_IJMatrixSetInitAllocation(hypre_IJMatrix *matrix,
HYPRE_Int factor)
{
hypre_IJMatrix *ijmatrix = (hypre_IJMatrix *) matrix;

if (!ijmatrix)
{
hypre_error_in_arg(1);
return hypre_error_flag;
}

if ( hypre_IJMatrixObjectType(ijmatrix) == HYPRE_PARCSR )
{
return ( hypre_IJMatrixSetInitAllocationParCSR(ijmatrix,
factor) );
}
else
{
hypre_error_in_arg(1);
}

return hypre_error_flag;
}

/*--------------------------------------------------------------------------
*--------------------------------------------------------------------------*/

HYPRE_Int
HYPRE_IJMatrixSetEarlyAssemble(hypre_IJMatrix *matrix,
HYPRE_Int early_assemble)
{
hypre_IJMatrix *ijmatrix = (hypre_IJMatrix *) matrix;

if (!ijmatrix)
{
hypre_error_in_arg(1);
return hypre_error_flag;
}

if ( hypre_IJMatrixObjectType(ijmatrix) == HYPRE_PARCSR )
{
return ( hypre_IJMatrixSetEarlyAssembleParCSR(ijmatrix,
early_assemble) );
}
else
{
hypre_error_in_arg(1);
}

return hypre_error_flag;
}

/*--------------------------------------------------------------------------
*--------------------------------------------------------------------------*/

HYPRE_Int
HYPRE_IJMatrixSetGrowFactor(hypre_IJMatrix *matrix,
HYPRE_Real factor)
{
hypre_IJMatrix *ijmatrix = (hypre_IJMatrix *) matrix;

if (!ijmatrix)
{
hypre_error_in_arg(1);
return hypre_error_flag;
}

if ( hypre_IJMatrixObjectType(ijmatrix) == HYPRE_PARCSR )
{
return ( hypre_IJMatrixSetGrowFactorParCSR(ijmatrix,
factor) );
}
else
{
hypre_error_in_arg(1);
}

return hypre_error_flag;
}

/*--------------------------------------------------------------------------
* HYPRE_IJMatrixRead
*
Expand Down
9 changes: 9 additions & 0 deletions src/IJ_mv/HYPRE_IJ_mv.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ HYPRE_Int HYPRE_IJMatrixSetDiagOffdSizes(HYPRE_IJMatrix matrix,
HYPRE_Int HYPRE_IJMatrixSetMaxOffProcElmts(HYPRE_IJMatrix matrix,
HYPRE_Int max_off_proc_elmts);

HYPRE_Int HYPRE_IJMatrixSetInitAllocation(HYPRE_IJMatrix matrix,
HYPRE_Int factor);

HYPRE_Int HYPRE_IJMatrixSetEarlyAssemble(HYPRE_IJMatrix matrix,
HYPRE_Int early_assemble);

HYPRE_Int HYPRE_IJMatrixSetGrowFactor(HYPRE_IJMatrix matrix,
HYPRE_Real factor);

/**
* (Optional) Sets the print level, if the user wants to print
* error messages. The default is 0, i.e. no error messages are printed.
Expand Down
84 changes: 84 additions & 0 deletions src/IJ_mv/IJMatrix_parcsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,90 @@ hypre_IJMatrixSetMaxOffProcElmtsParCSR(hypre_IJMatrix *matrix,
return hypre_error_flag;
}

/******************************************************************************
*
* hypre_IJMatrixSetInitAllocationParCSR
*
*****************************************************************************/

HYPRE_Int
hypre_IJMatrixSetInitAllocationParCSR(hypre_IJMatrix *matrix,
HYPRE_Int factor)
{
#if defined(HYPRE_USING_GPU)
hypre_AuxParCSRMatrix *aux_matrix = (hypre_AuxParCSRMatrix *) hypre_IJMatrixTranslator(matrix);
HYPRE_BigInt *row_partitioning = hypre_IJMatrixRowPartitioning(matrix);
HYPRE_BigInt *col_partitioning = hypre_IJMatrixColPartitioning(matrix);

if (!aux_matrix)
{
HYPRE_Int local_num_rows = (HYPRE_Int)(row_partitioning[1] - row_partitioning[0]);
HYPRE_Int local_num_cols = (HYPRE_Int)(col_partitioning[1] - col_partitioning[0]);
hypre_AuxParCSRMatrixCreate(&aux_matrix, local_num_rows, local_num_cols, NULL);
hypre_IJMatrixTranslator(matrix) = aux_matrix;
}
hypre_AuxParCSRMatrixInitAllocFactor(aux_matrix) = factor;
#endif

return hypre_error_flag;
}

/******************************************************************************
*
* hypre_IJMatrixSetEarlyAssembleParCSR
*
*****************************************************************************/

HYPRE_Int
hypre_IJMatrixSetEarlyAssembleParCSR(hypre_IJMatrix *matrix,
HYPRE_Int early_assemble)
{
#if defined(HYPRE_USING_GPU)
hypre_AuxParCSRMatrix *aux_matrix = (hypre_AuxParCSRMatrix *) hypre_IJMatrixTranslator(matrix);
HYPRE_BigInt *row_partitioning = hypre_IJMatrixRowPartitioning(matrix);
HYPRE_BigInt *col_partitioning = hypre_IJMatrixColPartitioning(matrix);

if (!aux_matrix)
{
HYPRE_Int local_num_rows = (HYPRE_Int)(row_partitioning[1] - row_partitioning[0]);
HYPRE_Int local_num_cols = (HYPRE_Int)(col_partitioning[1] - col_partitioning[0]);
hypre_AuxParCSRMatrixCreate(&aux_matrix, local_num_rows, local_num_cols, NULL);
hypre_IJMatrixTranslator(matrix) = aux_matrix;
}
hypre_AuxParCSRMatrixEarlyAssemble(aux_matrix) = early_assemble;
#endif

return hypre_error_flag;
}

/******************************************************************************
*
* hypre_IJMatrixSetGrowFactorParCSR
*
*****************************************************************************/

HYPRE_Int
hypre_IJMatrixSetGrowFactorParCSR(hypre_IJMatrix *matrix,
HYPRE_Real factor)
{
#if defined(HYPRE_USING_GPU)
hypre_AuxParCSRMatrix *aux_matrix = (hypre_AuxParCSRMatrix *) hypre_IJMatrixTranslator(matrix);
HYPRE_BigInt *row_partitioning = hypre_IJMatrixRowPartitioning(matrix);
HYPRE_BigInt *col_partitioning = hypre_IJMatrixColPartitioning(matrix);

if (!aux_matrix)
{
HYPRE_Int local_num_rows = (HYPRE_Int)(row_partitioning[1] - row_partitioning[0]);
HYPRE_Int local_num_cols = (HYPRE_Int)(col_partitioning[1] - col_partitioning[0]);
hypre_AuxParCSRMatrixCreate(&aux_matrix, local_num_rows, local_num_cols, NULL);
hypre_IJMatrixTranslator(matrix) = aux_matrix;
}
hypre_AuxParCSRMatrixGrowFactor(aux_matrix) = factor;
#endif

return hypre_error_flag;
}

/******************************************************************************
*
* hypre_IJMatrixInitializeParCSR
Expand Down
Loading