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 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f5aa42b
remove assertion
liruipeng May 2, 2024
2d764b9
add assert(0) when CUDA errors
liruipeng May 2, 2024
d15d70f
update assembly driver
liruipeng May 2, 2024
e43e11e
update headers
liruipeng May 2, 2024
78f58fb
apis
liruipeng May 2, 2024
e8cf56c
add defaults
liruipeng May 2, 2024
bf1344c
header
liruipeng May 2, 2024
2d189f2
main changes
liruipeng May 2, 2024
7706f5a
remove the shrink parameter
liruipeng May 2, 2024
a32df30
update assembly driver
liruipeng Jun 17, 2024
d5ce231
update device add values
liruipeng Jun 17, 2024
c7ae0b7
Merge branch 'master' of github.com:hypre-space/hypre into IJassembly…
liruipeng Jun 17, 2024
e734484
minor change
liruipeng Jun 18, 2024
9bb95a0
minor change
liruipeng Aug 8, 2024
9b89f6c
add sstruct interface
liruipeng Aug 8, 2024
90043a0
comment print
liruipeng Aug 8, 2024
b41bab8
add API call in test/sstruct.c
liruipeng Aug 13, 2024
808b068
tmp fix
liruipeng Sep 25, 2024
d007b83
minor changes
liruipeng Oct 9, 2024
f5ff87c
update the driver
liruipeng Oct 9, 2024
7af600d
Merge branch 'master' of github.com:hypre-space/hypre into IJassembly…
liruipeng Oct 10, 2024
f98e6bc
Merge branch 'master' of github.com:hypre-space/hypre into IJassembly…
liruipeng Jan 26, 2025
adc831e
fix format
liruipeng Jan 26, 2025
489c212
Merge branch 'master' of github.com:hypre-space/hypre into IJassembly…
liruipeng Jan 27, 2025
d3daa44
fix lassen tests
liruipeng Jan 28, 2025
78b931a
Merge branch 'master' of github.com:hypre-space/hypre into IJassembly…
liruipeng Jan 29, 2025
ea43c33
update .jobs/.sh
liruipeng Feb 3, 2025
2724033
Update src/IJ_mv/IJMatrix_parcsr.c
liruipeng Feb 21, 2025
9fdc406
Update src/IJ_mv/IJMatrix_parcsr.c
liruipeng Feb 21, 2025
71caefe
Update src/IJ_mv/IJMatrix_parcsr.c
liruipeng Feb 21, 2025
9e60bee
change a function name; add comments
liruipeng Feb 21, 2025
9906bee
Merge branch 'IJassemblymemory' of github.com:hypre-space/hypre into …
liruipeng Feb 21, 2025
a7c7882
a minor fix after reviewer comments
liruipeng Feb 21, 2025
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
26 changes: 26 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,32 @@ HYPRE_Int HYPRE_IJMatrixSetDiagOffdSizes(HYPRE_IJMatrix matrix,
HYPRE_Int HYPRE_IJMatrixSetMaxOffProcElmts(HYPRE_IJMatrix matrix,
HYPRE_Int max_off_proc_elmts);

/**
* (Optional, GPU only) Sets the initial memory allocation for matrix
* assemble, which factor * local number of rows
* Not collective.
**/
HYPRE_Int HYPRE_IJMatrixSetInitAllocation(HYPRE_IJMatrix matrix,
HYPRE_Int factor);

/**
* (Optional, GPU only) Sets if matrix assemble routine does reductions
* during the accumulation of the entries before calling HYPRE_IJMatrixAssemble.
* This early assemble feature may save the peak memory usage but requires
* extra work.
* Not collective.
**/
HYPRE_Int HYPRE_IJMatrixSetEarlyAssemble(HYPRE_IJMatrix matrix,
HYPRE_Int early_assemble);

/**
* (Optional, GPU only) Sets the grow factor of memory in matrix assemble when
* running out of memory.
* Not collective.
**/
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
93 changes: 93 additions & 0 deletions src/IJ_mv/IJMatrix_parcsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,99 @@ 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;
#else
HYPRE_UNUSED_VAR(matrix);
HYPRE_UNUSED_VAR(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;
#else
HYPRE_UNUSED_VAR(matrix);
HYPRE_UNUSED_VAR(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;
#else
HYPRE_UNUSED_VAR(matrix);
HYPRE_UNUSED_VAR(factor);
#endif

return hypre_error_flag;
}

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