Query: GMP completeness testing

Sergey Bochkanov sergey.bochkanov at alglib.net
Fri Jun 25 19:33:59 CEST 2010

Hello, Brad.

You wrote 25 июня 2010 г., 4:31:19:
> More generally, I'm curious how the other language efforts that have
> provided GMP interfaces (as itemized in your manual) have dealt with 
> completeness/correctness testing in case there are lessons learned there
> that would be helpful to us.

I  am working on C# interface. It is currently in beta stage... Can be
used  for  real work, but needs some polishing. I think I'll finish it
somewhere in the late 2010.

There are several lessons I've learned from this work.

First,  GMP  has very bast and regular interface. It can be exploited.
You  can  use  automatic code generation to: a) automatically generate
test  cases  for  GMP functions (i.e. IN-OUT values), b) automatically
generate  code  which  checks  test  cases  form  Chapel. You can also
automatically  generate  GMP-Chapel interface although it is debatable
whether  it  is  worth  the effort in your case (easy interoperability
with C).

Next,  it  is  better to create your own language to formally describe
GMP  interface  and to make it simple enough to parse, and full enough
to  describe all aspects of the interface. It may be human-readable or
may not - but it must be simple and full.

For  example,  you can describe mpz_fdiv_qr as

     mpz_fdiv_qr(out mpz q, out mpz r, in mpz n, in nonzero mpz d)

Note these "in", "out" and "nonzero" - they allow you to a) understand
what  is function's argument, and what is result, and b) to understand
how  to  generate random values for unit testing (n may be zero, but d
must be non-zero).

Another  lesson  -  sometimes  it  is better to manually handle "hard"
functions, like those which involve strings, than to write generalized
framework which can handle them.

P.S.  Sam Rawlins mentioned that he wants to test same edge cases that
GMP  team tests. In my opinion, it is unnecessary. Tests for interface
between some programming language ang GMP and tests for GMP itself are
two  different  kinds  of tests. GMP already has extensive set of unit
tests, so the only thing which needs testing is interfacing code.

P.P.S.  Where  Chapel is intended to be used? Am I right thinking that
is  it  language  mostly  for  supercomputers  with A LOT of CPU's and
distributed memory?

With best regards,
 Sergey                          mailto:sergey.bochkanov at alglib.net

More information about the gmp-discuss mailing list