From 75f768028c245aa0514a55d674d20a3eabb45192 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Sun, 23 Mar 2025 12:11:47 +0100 Subject: [PATCH] Fixes code and copyright for serial matching. --- amgprec/impl/aggregator/Matching.c | 277 +++++++++++++++++++++++++++++ amgprec/impl/aggregator/Matching.h | 70 ++++++++ 2 files changed, 347 insertions(+) diff --git a/amgprec/impl/aggregator/Matching.c b/amgprec/impl/aggregator/Matching.c index fa7ab67f..f3f32698 100644 --- a/amgprec/impl/aggregator/Matching.c +++ b/amgprec/impl/aggregator/Matching.c @@ -1,3 +1,73 @@ +/* + AMG4PSBLAS version 1.2 + Algebraic Multigrid Package + based on PSBLAS (Parallel Sparse BLAS version 3.9) + + (C) Copyright 2021 + + Salvatore Filippone + Pasqua D'Ambra + Fabio Durastante + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the AMG4PSBLAS group or the names of its contributors may + not be used to endorse or promote products derived from this + software without specific written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Includes material from BootCMatch, see copyright below. +*/ + +/* + BootCMatch + Bootstrap AMG based on Compatible weighted Matching, version 0.9 + (C) Copyright 2017 + Pasqua D'Ambra IAC-CNR, IT + Panayot S. Vassilevski Portland State University, OR USA + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the BootCMatch group or the names of its contributors may + not be used to endorse or promote products derived from this + software without specific written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BootCMatch GROUP OR ITS CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*/ #include "amg_config.h" #if defined(PSB_SERIAL_MPI) #include @@ -216,11 +286,218 @@ void dMatching(psb_l_t NLVer, psb_l_t NLEdge, return; } + +psb_l_t s_trymatch(psb_l_t rowindex, psb_l_t colindex, + psb_l_t nrows_W, psb_l_t *W_i, psb_l_t *W_j, psb_s_t *W_data, + psb_l_t *jrowindex, psb_l_t ljrowindex, + psb_l_t *jcolindex, psb_l_t ljcolindex, psb_l_t *rmatch) +{ + + psb_l_t tryrowmatch, trycolmatch; + psb_l_t i, j, k, nzrow_W, startj, kindex; + psb_s_t cweight, nweight; + + // psb_l_t *W_i = bcm_CSRMatrixI(W); + // psb_l_t *W_j = bcm_CSRMatrixJ(W); + // psb_l_t nrows_W = bcm_CSRMatrixNumRows(W); + // psb_s_t *W_data=bcm_CSRMatrixData(W); + + k=-1; + i=0; + while (i= 0) + { + ljrowindex=ljrowindex-1; + for(i=k; i= 0) + { + ljcolindex=ljcolindex-1; + for(i=k; i cweight && rmatch[tryrowmatch]==-1) + { + + nzrow_W=W_i[tryrowmatch+1]-W_i[tryrowmatch]; + psb_l_t *trymatchindexrow; + trymatchindexrow= (psb_l_t *) calloc(nzrow_W, sizeof(psb_l_t)); + + startj=W_i[tryrowmatch]; + for(k=0; k cweight && rmatch[trycolmatch]==-1) + { + nzrow_W=W_i[trycolmatch+1]-W_i[trycolmatch]; + psb_l_t *trymatchindexcol; + trymatchindexcol= (psb_l_t *) calloc(nzrow_W, sizeof(psb_l_t)); + + startj=W_i[trycolmatch]; + for(k=0; k