Skip to content

Commit

Permalink
Get array cache in assembly loop only if length > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Mar 11, 2022
1 parent 803333a commit 5c4b5f2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/FESpaces/SparseMatrixAssemblers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ function symbolic_loop_matrix!(A,a::GenericSparseMatrixAssembler,matdata)
for (cellmat,_cellidsrows,_cellidscols) in zip(matdata...)
cellidsrows = map_cell_rows(a.strategy,_cellidsrows)
cellidscols = map_cell_cols(a.strategy,_cellidscols)
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
@assert length(cellidscols) == length(cellidsrows)
if length(cellidscols) > 0
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
mat1 = get_mat(first(cellmat))
rows1 = getindex!(rows_cache,cellidsrows,1)
cols1 = getindex!(cols_cache,cellidscols,1)
Expand All @@ -233,12 +233,12 @@ function numeric_loop_matrix!(A,a::GenericSparseMatrixAssembler,matdata)
for (cellmat,_cellidsrows,_cellidscols) in zip(matdata...)
cellidsrows = map_cell_rows(a.strategy,_cellidsrows)
cellidscols = map_cell_cols(a.strategy,_cellidscols)
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
vals_cache = array_cache(cellmat)
@assert length(cellidscols) == length(cellidsrows)
@assert length(cellmat) == length(cellidsrows)
if length(cellmat) > 0
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
vals_cache = array_cache(cellmat)
mat1 = getindex!(vals_cache,cellmat,1)
rows1 = getindex!(rows_cache,cellidsrows,1)
cols1 = getindex!(cols_cache,cellidscols,1)
Expand Down Expand Up @@ -270,8 +270,8 @@ function symbolic_loop_vector!(b,a::GenericSparseMatrixAssembler,vecdata)
end
for (cellvec,_cellids) in zip(vecdata...)
cellids = map_cell_rows(a.strategy,_cellids)
rows_cache = array_cache(cellids)
if length(cellids) > 0
rows_cache = array_cache(cellids)
vec1 = get_vec(first(cellvec))
rows1 = getindex!(rows_cache,cellids,1)
touch! = TouchEntriesMap()
Expand All @@ -295,9 +295,9 @@ end
function numeric_loop_vector!(b,a::GenericSparseMatrixAssembler,vecdata)
for (cellvec, _cellids) in zip(vecdata...)
cellids = map_cell_rows(a.strategy,_cellids)
rows_cache = array_cache(cellids)
vals_cache = array_cache(cellvec)
if length(cellvec) > 0
rows_cache = array_cache(cellids)
vals_cache = array_cache(cellvec)
vals1 = getindex!(vals_cache,cellvec,1)
rows1 = getindex!(rows_cache,cellids,1)
add! = AddEntriesMap(+)
Expand Down Expand Up @@ -333,12 +333,12 @@ function numeric_loop_matrix_and_vector!(A,b,a::GenericSparseMatrixAssembler,dat
for (cellmatvec,_cellidsrows,_cellidscols) in zip(matvecdata...)
cellidsrows = map_cell_rows(a.strategy,_cellidsrows)
cellidscols = map_cell_cols(a.strategy,_cellidscols)
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
vals_cache = array_cache(cellmatvec)
@assert length(cellidscols) == length(cellidsrows)
@assert length(cellmatvec) == length(cellidsrows)
if length(cellmatvec) > 0
rows_cache = array_cache(cellidsrows)
cols_cache = array_cache(cellidscols)
vals_cache = array_cache(cellmatvec)
mat1, vec1 = getindex!(vals_cache,cellmatvec,1)
rows1 = getindex!(rows_cache,cellidsrows,1)
cols1 = getindex!(cols_cache,cellidscols,1)
Expand Down

0 comments on commit 5c4b5f2

Please sign in to comment.