You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/03/15 15:58:40 UTC

[commons-rng] branch master updated: Update the stress test c-code and documentation for TestU01 src install.

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git


The following commit(s) were added to refs/heads/master by this push:
     new b007cb2  Update the stress test c-code and documentation for TestU01 src install.
b007cb2 is described below

commit b007cb2eb2bb1bdcee8c7dc3471d69dc4d47f66c
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Mar 15 15:58:35 2019 +0000

    Update the stress test c-code and documentation for TestU01 src install.
---
 .../examples-stress/src/main/c/stdin2testu01.c     | 20 ++++++-
 .../examples-stress/stress_test.md                 | 65 ++++++++++++++++------
 2 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/commons-rng-examples/examples-stress/src/main/c/stdin2testu01.c b/commons-rng-examples/examples-stress/src/main/c/stdin2testu01.c
index d1a4a6a..f17a9cc 100644
--- a/commons-rng-examples/examples-stress/src/main/c/stdin2testu01.c
+++ b/commons-rng-examples/examples-stress/src/main/c/stdin2testu01.c
@@ -29,9 +29,23 @@
 #include <unistd.h>
 #include <string.h>
 
-#include <testu01/unif01.h>
-#include <testu01/bbattery.h>
-#include <testu01/util.h>
+/*
+ * Use this flag to switch the includes for TestU01.
+ * - An install from the TestU01 source puts headers directly
+ *   into the <install directory> (e.g. /usr/local/include).
+ * - The linux package install uses a testu01 sub-directory.
+ */
+#define TEST_U01_SRC 0
+
+#if TEST_U01_SRC
+  #include <unif01.h>
+  #include <bbattery.h>
+  #include <util.h>
+#else
+  #include <testu01/unif01.h>
+  #include <testu01/bbattery.h>
+  #include <testu01/util.h>
+#endif
 
 #define TU_S "SmallCrush"
 #define TU_C "Crush"
diff --git a/commons-rng-examples/examples-stress/stress_test.md b/commons-rng-examples/examples-stress/stress_test.md
index 081ff8b..699c2d3 100644
--- a/commons-rng-examples/examples-stress/stress_test.md
+++ b/commons-rng-examples/examples-stress/stress_test.md
@@ -19,37 +19,60 @@ Apache Commons RNG Stress Test Example
 ===================
 
 The stress test module contains an application for calling external tools that perform stringent
-uniformity tests. The following shows an example of how to run DieHarder and TestU01.
+uniformity tests. The following shows an example of how to run **DieHarder** and **TestU01**.
 
-Installation on Linux
----------------------
+Installation on Linux/MacOS
+---------------------------
 
 This assumes that the source code has been checked out and the current working directory is
 `commons-rng-examples/examples-stress`.
 
 ### TestU01
 
-This can be installed from [Test01](http://simul.iro.umontreal.ca/testu01/tu01.html) or using
-the available packages:
+This can be installed from [TestU01](http://simul.iro.umontreal.ca/testu01/tu01.html) or using
+the available packages (linux):
 
         > apt-get install libtestu01 libtestu01-dev testu01-bin
 
-A simple bridge is provided to read the integers from `stdin` and pass them to the TestU01 library.
-This can be compiled using:
+If installing **TestU01** from source then it is recommended to do this using an install directory
+to avoid header clashes as the install puts headers directly into `<install directory>/include`:
 
-        > gcc src/main/c/stdin2testu01.c -o stdin2testu01 -ltestu01 -lprobdist -lmylib -lm
+        > ./configure --prefix=/usr/local/testu01
+        > make
+        > make install
+
+A simple bridge is provided to read the integers from `stdin` and pass them to the **TestU01** library.
+This can be compiled using one of the following (depending on the library names):
+
+         > gcc src/main/c/stdin2testu01.c -o stdin2testu01 -ltestu01 -lprobdist -lmylib -lm
+         > gcc src/main/c/stdin2testu01.c -o stdin2testu01 -ltestu01 \
+               -ltestu01probdist -ltestu01mylib -lm
+
+Note: If **TestU01** was installed from source then the `stdin2testu01.c` may have to be modified to
+use different headers. Open the source and update to:
+
+`#define TEST_U01_SRC 1`
+
+Then compile with the `<install directory>/include` and `lib` directories:
+
+        > gcc src/main/c/stdin2testu01.c -o stdin2testu01 \
+              -I/usr/local/testu01/include \
+              -L/usr/local/testu01/lib \
+              -ltestu01 -lprobdist -lmylib -lm
 
 ### DieHarder
 
-This can be install from [DieHarder](http://webhome.phy.duke.edu/~rgb/General/dieharder.php) or
-using the available package:
+This can be installed from [DieHarder](http://webhome.phy.duke.edu/~rgb/General/dieharder.php) or
+using the available packages:
 
         > apt-get install dieharder
+        > brew install dieharder
 
-The `dieharder` executable can read integers from `stdin` for analysis.
+The `dieharder` executable can read integers from `stdin` for analysis so no additional steps are
+required.
 
-Running on Linux
-----------------
+Running on Linux/MacOS
+----------------------
 
 Build the `examples-stress` jar file:
 
@@ -65,12 +88,22 @@ The jar file requires the following arguments:
 | n | Number of processors | 4 |
 | GeneratorsList class | Fully qualified class name of a provider for the supported random generators | org.apache.commons.rng.examples.stress.(GeneratorsList/IntGeneratorsList/LongGeneratorsList) |
 | executable | The test tool | dieharder, stdin2testu01 |
-| ... | Arguments for the test tool | dieharder: -a -g 200 -Y 1 -k 2, stdin2testu01: SmallCrush, Crush, BigCrush |
+| ... | Arguments for the test tool | dieharder: -a -g 200 -Y 1 -k 2 <br/> stdin2testu01: SmallCrush, Crush, BigCrush |
 
 ### TestU01
 
-        > java -jar target/examples-stress.jar target/tu_ 4 org.apache.commons.rng.examples.stress.GeneratorsList ./stdin2testu01 BigCrush
+        > java -jar target/examples-stress.jar \
+              target/tu_ \
+              4 \
+              org.apache.commons.rng.examples.stress.GeneratorsList \
+              ./stdin2testu01 \
+              BigCrush
 
 ### DieHarder
 
-        > java -jar target/examples-stress.jar target/dh_ 4 org.apache.commons.rng.examples.stress.GeneratorsList /usr/bin/dieharder -a -g 200 -Y 1 -k 2
+        > java -jar target/examples-stress.jar \
+              target/dh_ \
+              4 \
+              org.apache.commons.rng.examples.stress.GeneratorsList \
+              /usr/bin/dieharder \
+              -a -g 200 -Y 1 -k 2