[petsc-dev] Make PetscHash publicly accessible

Matthew Knepley knepley at gmail.com
Fri Apr 22 09:31:31 CDT 2016


On Fri, Apr 22, 2016 at 9:25 AM, Jed Brown <jed at jedbrown.org> wrote:

> Matthew Knepley <knepley at gmail.com> writes:
> > Sweeping generalization not actually true. The wrappers do setup the
> > particular
> > keys we want inside PETSc,
>
> All 3 invocations of KHASH_INIT amid 500 lines.


You are wrong in this case. The HashIJ is not trivial, and cannot be done
easily inline. What is the problem here?

  Matt


>
> > and do bundle some multiple operation calls.
>
> Some, yes, though some of that bundling produces demonstrably less
> efficient interfaces.
>
> commit da33aca0a8f0fe1631697dcf59d191f75b34b5c6
> Author: Matthew G. Knepley <knepley at gmail.com>
> Date:   Fri Nov 8 15:40:59 2013 -0600
>
>     Sys ex26: Jed is right that this is much faster
>
>         Modified   src/sys/examples/tests/ex26.c
> diff --git a/src/sys/examples/tests/ex26.c b/src/sys/examples/tests/ex26.c
> index e8cc50a..30ed523 100644
> --- a/src/sys/examples/tests/ex26.c
> +++ b/src/sys/examples/tests/ex26.c
> @@ -22,8 +22,13 @@ int main(int argc, char **argv)
>
>        key.i = PetscMin(i, j);
>        key.j = PetscMax(i, j);
> +#if 1
> +      khint_t ret, idx = kh_put(HASHIJ, table->ht, key, &ret);
> +      if (ret == 1) kh_val(table->ht, idx).n = newp++;
> +#else
>        ierr  = PetscHashIJGet(table, key, &p);CHKERRQ(ierr);
>        if (p < 0) {ierr = PetscHashIJAdd(table, key,
> newp++);CHKERRQ(ierr);}
> +#endif
>      }
>    }
>    ierr = PetscHashIJDestroy(&table);CHKERRQ(ierr);
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160422/a8b5476f/attachment.html>


More information about the petsc-dev mailing list