Skip to content

Commit

Permalink
Introduce loadable pseudo-random number generators.
Browse files Browse the repository at this point in the history
N.B. The PRNG interface introduced here is subject to review and may change.

PRNGs are per-thread and may be changed with the new loadrng() standard
function. Two PRNGs are present:
   IconEx   A reimplementation of the traditional generator
            as a loadable library.
   Rabbit   A cryptographically strong PRNG from the eSTREAM project.
Other PRNGs -- probably RanLux and the Mersenne Twister -- will follow.
  • Loading branch information
Don-Ward committed Jan 13, 2022
1 parent 063ece4 commit 5f062e4
Show file tree
Hide file tree
Showing 50 changed files with 10,184 additions and 17 deletions.
Binary file added doc/utr/utr-prng/larson.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,305 changes: 2,305 additions & 0 deletions doc/utr/utr-prng/utr-prng.tex

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions doc/utr/utr-prng/utr.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% tr.sty
\gdef\@abstract{}\gdef\@trnumber{}
\gdef\@affiliation{University of Idaho\\Department of Computer Science\\Moscow, ID, 83844, USA}
\def\maketitle{\begin{titlepage}
\let\footnotesize\small \let\footnoterule\relax \setcounter{page}{0}
\null
\vfil
\vskip 40pt \begin{center}
{\LARGE\bf \@title \par} \vskip 3em {\large \lineskip .75em
{\bf \@author}
\par}
\vskip 1.0em {\bf Unicon Technical Report: \@trnumber}\par
\vskip 1.0em {\large\bf \@date}
\vskip 5.5em \par

{\bf Abstract}
\begin{quote}
\@abstract
\end{quote}
\vskip 0.8in
{\large\bf
Unicon Project\\
http://unicon.org\\
\ \\
\@affiliation
}
\end{center}

\@thanks
\vfil
\null
\end{titlepage}
\setcounter{footnote}{0} \let\thanks\relax
\gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\maketitle\relax}
\def\trnumber#1{\gdef\@trnumber{#1}}
\def\abstract#1{\gdef\@abstract{#1}}
\def\affiliation#1{\gdef\@affiliation{#1}}

21 changes: 20 additions & 1 deletion plugins/README
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
Unicon Plugins - February 2017
------------------------------

This directory is home for Unicon's official shared/loadable objects and their sources. This is where some of the new experimental features are added that eventually could be moved to be part of the language, or those features that are deemed to be nonessential to be added as built-in to the language. Contributions are welcome. If you plan to contribute a new feature in the form of a shared object please follow the guidelines below as this makes it easier for us to integrate them with our build system on various platforms.
This directory is home for Unicon's official shared/loadable objects and their
sources. This is where some of the new experimental features are added that
eventually could be moved to be part of the language, or those features that are
deemed to be nonessential to be added as built-in to the language. Contributions
are welcome. If you plan to contribute a new feature in the form of a shared
object please follow the guidelines below as this makes it easier for us to
integrate them with our build system on various platforms.

1- Make sure every source file has a licence at the top
2- Please use consistent formatting across your source files
3- Add rules to the make file to build your shared library

Note that, as of August 2019, there are now two different kinds of additional
features:
Conventional plugins, as before.
Random Number Generator (RNG) shared libraries.

The RNG libraries are implemented differently to a conventional plugin and each
library is located in a separate subdirectory of plugins/rngLibraries. The
simplest example is in plugins/rngLibraries/rngIconEx, which contains a
re-implementation of the built-in (Icon) generator as a shared library.
The "Ex" may be interpreted as "External" or "Example" (or both).

Note that, for any shared RNG library to work, your implementation of Unicon
must be built with the symbol RngLibrary defined.
64 changes: 64 additions & 0 deletions plugins/rngLibraries/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
################################################################################
#
# This file is released under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE
# (LGPL) version 2. The licence may be found in the root directory of the Unicon
# source directory in the file COPYING.
#
################################################################################
#
# Makefile for the rng shared libraries
#
# Don Ward
# March 2021
#
################################################################################
include ../../Makedefs

.PHONY: Pure clean install test testPrograms

TESTPROGS = rngConfidence rngPutGet rngSpeed
UNILIB = $(shell unicon -features | grep "Libraries at" | sed -e "s/Libraries at //")

default: all_prngs

all_prngs:
$(MAKE) -C rngIconEx
$(MAKE) -C rngRbt

test: all_prngs testPrograms
$(MAKE) -C rngIconEx test
$(MAKE) -C rngRbt test
./rngConfidence

testPrograms: $(TESTPROGS)

rngConfidence: rngConfidence.icn
unicon -s $^ -o $@

rngPutGet: rngPutGet.icn
unicon -s $^ -o $@

rngSpeed: rngSpeed.icn
unicon -s $^ -o $@

install: all_prngs
# Each install places a shared library in plugins/lib (a.k.a ../lib)
@$(MAKE) -C rngIconEx install
@$(MAKE) -C rngRbt install
# If Unicon is installed somewhere, place the shared libraries in
# the installed location.
@if test "X$(UNILIB)" != "X" ; then \
cp ../lib/rngIconEx.so $(UNILIB)/plugins/lib; \
cp ../lib/rngRbt.so $(UNILIB)/plugins/lib; \
fi

clean:
$(MAKE) -C rngIconEx clean
$(MAKE) -C rngRbt clean
rm -f $(TESTPROGS)

Pure:
$(MAKE) -C rngIconEx Pure
$(MAKE) -C rngRbt Pure
rm -f $(TESTPROGS)

Loading

0 comments on commit 5f062e4

Please sign in to comment.