[petsc-dev] Make PetscHash publicly accessible

Jed Brown jed at jedbrown.org
Fri Apr 22 09:25:02 CDT 2016


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.

> 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);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160422/20d69f80/attachment.sig>


More information about the petsc-dev mailing list