Skip to content

Commit

Permalink
Change the symbolic assembly loop for matrix_vector assembly such that
Browse files Browse the repository at this point in the history
it also takes into account the symbolic part corresponding to vector
entries.

This is a feature required to fix issue 142 in gridapdistributed.jl

gridap/GridapDistributed.jl#142
  • Loading branch information
amartinhuertas committed Jan 28, 2024
1 parent 07d6e2f commit d60d631
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/FESpaces/SparseMatrixAssemblers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,44 @@ end
end

function symbolic_loop_matrix_and_vector!(A,b,a::SparseMatrixAssembler,data)
if LoopStyle(A) == DoNotLoop()
return A, b
end
matvecdata, matdata, vecdata = data
symbolic_loop_matrix!(A,a,matvecdata)
strategy = get_assembly_strategy(a)
for (cellmatvec,_cellidsrows,_cellidscols) in zip(matvecdata...)
cellidsrows = map_cell_rows(strategy,_cellidsrows)
cellidscols = map_cell_cols(strategy,_cellidscols)
@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)
touch! = TouchEntriesMap()
touch_mat_cache = return_cache(touch!,A,mat1,rows1,cols1)
touch_vec_cache = return_cache(touch!,b,vec1,rows1)
caches = touch_mat_cache, touch_vec_cache,rows_cache, cols_cache
_symbolic_loop_matvec!(A,b,caches,cellidsrows,cellidscols,mat1,vec1)
end
end
symbolic_loop_matrix!(A,a,matdata)
symbolic_loop_vector!(b,a,vecdata)
A, b
end

@noinline function _symbolic_loop_matvec!(A,b,caches,cell_rows,cell_cols,mat1,vec1)
touch_mat_cache, touch_vec_cache, rows_cache, cols_cache = caches
touch! = TouchEntriesMap()
for cell in 1:length(cell_cols)
rows = getindex!(rows_cache,cell_rows,cell)
cols = getindex!(cols_cache,cell_cols,cell)
evaluate!(touch_mat_cache,touch!,A,mat1,rows,cols)
evaluate!(touch_vec_cache,touch!,b,vec1,rows)
end
end

function numeric_loop_matrix_and_vector!(A,b,a::SparseMatrixAssembler,data)
Expand Down

0 comments on commit d60d631

Please sign in to comment.