Skip to content
Commits on Source (4)
exabayes (1.5-1) UNRELEASED; urgency=medium
exabayes (1.5+dfsg-1) UNRELEASED; urgency=medium
* Initial release (Closes: #<bug>)
-- DMPT <debian-med-packaging@lists.alioth.debian.org> Thu, 23 Feb 2017 15:55:15 +0100
-- Andreas Tille <tille@debian.org> Mon, 15 May 2017 15:01:56 +0200
......@@ -6,6 +6,9 @@ Priority: optional
Build-Depends: debhelper (>= 10),
autoconf-archive,
bibtex2html,
librandom123-dev,
libncl-dev,
libpll-dev,
emacs,
texlive-fonts-recommended,
texlive-latex-extra,
......
......@@ -2,6 +2,8 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ExaBayes
Upstream-Contact: Andre J. Aberer <andre.aberer@h-its.org>
Source: https://github.com/aberer/exabayes/releases
Files-Excluded: */ax_*.m4
lib
Files: *
Copyright: © 20xx-20yy <upstream>
......
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
AC_REREQ([2.67])
AC_INIT([exabayes],[1.5],[exabayes-at-googlegroups-dot-com])
-m4_include([./m4/ax_cxx_compile_stdcxx_11.m4])
+m4_include([/usr/share/aclocal/ax_cxx_compile_stdcxx_11.m4])
m4_include([./m4/lx_find_mpi.m4])
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,8 +3,8 @@
AUTOMAKE_OPTIONS= foreign subdir-objects
-EXTRA_DIST= src/releaseDate.hpp lib/Random123-1.08 LICENSE.txt lib/pll/avxLikelihood.c examples
-noinst_LIBRARIES=libbayes.a libncl.a libcommdummy.a libpll.a libpll_model.a
+EXTRA_DIST= src/releaseDate.hpp LICENSE.txt examples
+noinst_LIBRARIES=libcommdummy.a
bin_PROGRAMS = yggdrasil parser-exabayes sdsf postProcParam credibleSet extractBips consense
dist_doc_DATA = ./CHANGELOG ./README.md ./COPYING
@@ -115,15 +115,15 @@ folders=$(shell find $(top_srcdir)/src -
SRCINCLUDE=$(shell echo $(folders) | tr ' ' '\n' | sed "s/\(.*\)/-I\1/" | tr '\n' ' ')
SRCINCLUDE+= -I$(top_srcdir)/src/comm/ -I$(top_srcdir)/src/comm/threads
-RAND123_INCLUDES=-isystem $(top_srcdir)/lib/Random123-1.08/include/Random123 -isystem $(top_srcdir)/lib/Random123-1.08/include -isystem $(top_srcdir)/lib/Random123-1.08/examples
-NCL_INCLUDES=-isystem $(top_srcdir)/lib/ncl-2.1.18
+RAND123_INCLUDES=-isystem /usr/include/Random123
+NCL_INCLUDES=-isystem /usr/include/ncl
BAYES_COMMON= $(RAND123_INCLUDES) $(NCL_INCLUDES) $(SRCINCLUDE)
BAYES_INCLUDES=$(BAYES_COMMON) -I$(top_srcdir)/src/comm/dummy
BAYES_INCLUDES_PARA= $(BAYES_COMMON)-I$(top_srcdir)/src/comm/mpi
-seqlibs= libncl.a libbayes.a libcommdummy.a libpll.a libpll_model.a libncl.a
-paralibs= libbayes.a libcommmpi.a libpll.a libpll_model.a libncl.a
-
+seqlibs= libbayes.a libcommdummy.a
+paralibs= libbayes.a libcommmpi.a
+syslibs= -lncl -lpll
################################################################
# auto generated sources
@@ -137,7 +137,6 @@ my-update-src:
@echo "libbayes_a_SOURCES=" $(shell echo "$(top_srcdir)/src/common.h $(top_srcdir)/src/pll.h") $(shell find $(folders) -maxdepth 1 -name "*.[cht]pp" ) >> src.am
@echo "libcommdummy_a_SOURCES=" $(shell find ${dummyFolds} -maxdepth 1 -name "*.[cht]pp" ) >> src.am
@echo "libcommmpi_a_SOURCES=" $(shell find ${mpiFolds} -maxdepth 1 -name "*.[cht]pp" ) >> src.am
- @echo "libncl_a_SOURCES=" $(shell find $(top_srcdir)/lib/ncl-2.1.18/ncl -name "*.[cht]") $(shell find $(top_srcdir)/lib/ncl-2.1.18/ncl -name "*.[cht]pp") >> src.am
include src.am
@@ -162,87 +161,54 @@ endif
libbayes_a_CXXFLAGS= $(AM_CXXFLAGS) -O3 $(BAYES_INCLUDES)
libbayes_a_CFLAGS=-O2 $(BAYES_INCLUDES)
-
-################################################################
-# libpll
-
-libpll_a_SOURCES=./lib/pll/alignment.c ./lib/pll/evaluateGenericSpecial.c \
-./lib/pll/globalVariables.h ./lib/pll/lexer.c ./lib/pll/mem_alloc.h \
-./lib/pll/genericParallelization.h ./lib/pll/newick.h ./lib/pll/pllInternal.h \
-./lib/pll/recom.c ./lib/pll/stack.h ./lib/pll/utils.c \
-./lib/pll/evaluatePartialGenericSpecial.c ./lib/pll/lexer.h \
-./lib/pll/newviewGenericSpecial.c ./lib/pll/pll-renamed.h \
-./lib/pll/restartHashTable.c ./lib/pll/topologies.c ./lib/pll/bipartitionList.c \
-./lib/pll/fastDNAparsimony.c ./lib/pll/makenewzGenericSpecial.c \
-./lib/pll/optimizeModel.c ./lib/pll/queue.c ./lib/pll/searchAlgo.c \
-./lib/pll/trash.c ./lib/pll/cycle.h ./lib/pll/hash.c ./lib/pll/parsePartition.c \
-./lib/pll/queue.h ./lib/pll/ssort.c ./lib/pll/treeIO.c ./lib/pll/errcodes.h \
-./lib/pll/hash.h ./lib/pll/newick.c ./lib/pll/parsePartition.h \
-./lib/pll/randomTree.c ./lib/pll/stack.c ./lib/pll/treeIO.h \
-./src/avxConditional.c
-
-libpll_model_a_SOURCES= ./lib/pll/models.c
-libpll_model_a_CFLAGS=$(AM_CFLAGS) -w $(SRCINCLUDE) -O1 $(MIC_FLAGS)
-
-libpll_a_CFLAGS=$(AM_CFLAGS) -w -O2 $(SRCINCLUDE) $(MIC_FLAGS)
-
-if WITH_MIC
-libpll_a_SOURCES+=./lib/pll/mic_native_aa.c ./lib/pll/mic_native_dna.c ./lib/pll/mic_native.h
-endif
-
-
################################################################
# exabayes
exabayes_SOURCES = ./src/apps/exabayes.cpp
exabayes_CXXFLAGS= $(AM_CXXFLAGS) -O3 $(BAYES_INCLUDES)
exabayes_LDFLAGS=$(MPI_CXXLDFLAGS)
-exabayes_LDADD= $(paralibs) $(MPI_CXXLDFLAGS)
+exabayes_LDADD= $(paralibs) $(syslibs) $(MPI_CXXLDFLAGS)
################################################################
# yggdrasil
yggdrasil_SOURCES = ./src/apps/exabayes.cpp
yggdrasil_CXXFLAGS=$(AM_CXXFLAGS) -O3 $(BAYES_INCLUDES) -D_IS_YGG
-yggdrasil_LDADD=$(seqlibs)
+yggdrasil_LDADD=$(seqlibs) $(syslibs)
################################################################
# SDSF
sdsf_SOURCES= ./src/apps/sdsf.cpp
sdsf_CXXFLAGS= $(AM_CXXFLAGS) -O3 $(BAYES_INCLUDES)
-sdsf_LDADD= $(seqlibs)
+sdsf_LDADD= $(seqlibs) $(syslibs)
################################################################
# the parser
parser_exabayes_SOURCES=./src/apps/parser.cpp
parser_exabayes_CXXFLAGS=-O3 $(AM_CXXFLAGS) $(BAYES_INCLUDES) -Wno-deprecated-writable-strings
-parser_exabayes_LDADD=$(seqlibs)
+parser_exabayes_LDADD=$(seqlibs) $(syslibs)
################################################################
# extractBips
extractBips_SOURCES=./src/apps/extractBips.cpp
extractBips_CXXFLAGS=-O3 $(AM_CXXFLAGS) $(BAYES_INCLUDES)
-extractBips_LDADD=$(seqlibs)
+extractBips_LDADD=$(seqlibs) $(syslibs)
################################################################
# consense
consense_SOURCES=./src/apps/consense.cpp
consense_CXXFLAGS=-O3 $(AM_CXXFLAGS) $(BAYES_INCLUDES)
-consense_LDADD=$(seqlibs)
+consense_LDADD=$(seqlibs) $(syslibs)
################################################################
# credibleSet
credibleSet_SOURCES=./src/apps/credibleSet.cpp
credibleSet_CXXFLAGS=-O3 $(AM_CXXFLAGS) $(BAYES_INCLUDES)
-credibleSet_LDADD= $(seqlibs)
+credibleSet_LDADD= $(seqlibs) $(syslibs)
################################################################
# postProcParam
postProcParam_SOURCES=./src/apps/postProcParam.cpp
postProcParam_CXXFLAGS=-O3 $(AM_CXXFLAGS) $(BAYES_INCLUDES)
-postProcParam_LDADD=$(seqlibs)
-
-################################################################
-# ncl
-libncl_a_CXXFLAGS= -w $(AM_CXXFLAGS) -O3 $(NCL_INCLUDES) -D__STRICT_ANSI__
+postProcParam_LDADD=$(seqlibs) $(syslibs)
################################################################
# exatest
@@ -254,7 +220,7 @@ endif
exatest_SOURCES = ./tests/exatest.cpp
exatest_CXXFLAGS=$(AM_CXXFLAGS) -O3 $(BAYES_INCLUDES) -D_IS_YGG
exatest_LDFLAGS=-L/usr/local/lib -lgtest -lpthread
-exatest_LDADD= $(seqlibs)
+exatest_LDADD= $(seqlibs) $(syslibs)
if WITH_MPI
exatest_CXXFLAGS+=-D_WITH_MPI
--- a/src.am
+++ b/src.am
@@ -1,4 +1,3 @@
libbayes_a_SOURCES= ./src/common.h ./src/pll.h ./src/TreePrinter.cpp ./src/TreeRandomizer.hpp ./src/TreeRandomizer.cpp ./src/TreePrinter.hpp ./src/releaseDate.hpp ./src/branches/BranchLengthOptimizer.cpp ./src/branches/TreeTraverser.hpp ./src/branches/ComplexTuner.cpp ./src/branches/BranchSetProposer.cpp ./src/branches/TreeTraverser.tpp ./src/branches/WeibullProposer.hpp ./src/branches/WeibullProposer.cpp ./src/branches/ComplexTuner.hpp ./src/branches/BranchBackup.cpp ./src/branches/BranchSetProposer.hpp ./src/branches/GammaProposer.cpp ./src/branches/TreeTraverser.cpp ./src/branches/OptimizedParameter.hpp ./src/branches/DistributionProposer.hpp ./src/branches/OptimizedParameter.cpp ./src/branches/GammaProposer.hpp ./src/branches/BranchLengthOptimizer.hpp ./src/branches/BranchBackup.hpp ./src/eval/FullCachePolicy.cpp ./src/eval/NoCachePolicy.hpp ./src/eval/ArrayRestorer.cpp ./src/eval/NoCachePolicy.cpp ./src/eval/ArrayPolicy.hpp ./src/eval/ArrayReservoir.hpp ./src/eval/ArrayReservoir.cpp ./src/eval/FullCachePolicy.hpp ./src/eval/ArrayOrientation.cpp ./src/eval/LikelihoodEvaluator.hpp ./src/eval/ParsimonyEvaluator.hpp ./src/eval/ArrayOrientation.hpp ./src/eval/PartitionLikelihood.hpp ./src/eval/ArrayRestorer.hpp ./src/eval/LikelihoodEvaluator.cpp ./src/eval/ParsimonyEvaluator.cpp ./src/system/ByteFile.cpp ./src/system/Teebuf.hpp ./src/system/VectAlign.hpp ./src/system/ByteFile.tpp ./src/system/BoundsChecker.hpp ./src/system/FlagType.hpp ./src/system/BoundsChecker.cpp ./src/system/NastyGlobalVariables.cpp ./src/system/log_double.hpp ./src/system/BandWidthTest.cpp ./src/system/Serializable.cpp ./src/system/Teebuf.cpp ./src/system/RunFactory.cpp ./src/system/TimeTracker.cpp ./src/system/TimeTracker.hpp ./src/system/Serializable.hpp ./src/system/TeeStream.hpp ./src/system/BitMask.hpp ./src/system/extensions.cpp ./src/system/log_double.cpp ./src/system/PartitionAssignment.cpp ./src/system/BandWidthTest.hpp ./src/system/extensions.hpp ./src/system/ProposalRegistry.cpp ./src/system/RunFactory.hpp ./src/system/SyncOut.hpp ./src/system/memory.hpp ./src/system/BitMask.cpp ./src/system/PartitionAssignment.hpp ./src/system/ByteFile.hpp ./src/system/AlignedAllocator.hpp ./src/system/ProposalRegistry.hpp ./src/system/GlobalVariables.hpp ./src/math/Arithmetics.cpp ./src/math/Randomness.hpp ./src/math/Density.cpp ./src/math/brent.hpp ./src/math/Arithmetics.hpp ./src/math/Density.hpp ./src/math/brent.cpp ./src/math/Randomness.cpp ./src/mcmc/Chain.cpp ./src/mcmc/SuccessCounter.cpp ./src/mcmc/SampleMaster.cpp ./src/mcmc/ParameterList.cpp ./src/mcmc/SampleMaster.hpp ./src/mcmc/ParameterList.hpp ./src/mcmc/CoupledChains.hpp ./src/mcmc/Chain.hpp ./src/mcmc/SwapMatrix.hpp ./src/mcmc/CoupledChains.cpp ./src/mcmc/SwapMatrix.cpp ./src/mcmc/SuccessCounter.hpp ./src/config/BlockPrior.cpp ./src/config/BlockParams.hpp ./src/config/BlockRunParameters.cpp ./src/config/ExaBlock.hpp ./src/config/ExaBlock.cpp ./src/config/CommandLine.cpp ./src/config/BlockPrior.hpp ./src/config/BlockRunParameters.hpp ./src/config/MemoryMode.hpp ./src/config/BlockProposalConfig.hpp ./src/config/BlockProposalConfig.cpp ./src/config/MemoryMode.cpp ./src/config/BlockParams.cpp ./src/config/CommandLine.hpp ./src/config/ConfigReader.hpp ./src/contrib/CredibleSet.hpp ./src/contrib/SplitFreqAssessor.hpp ./src/contrib/AlignmentPLL.cpp ./src/contrib/CredibleSet.cpp ./src/contrib/ConsensusTree.cpp ./src/contrib/BipartitionExtractor.cpp ./src/contrib/SplitFreqAssessor.cpp ./src/contrib/AlignmentPLL.hpp ./src/contrib/BipartitionExtractor.hpp ./src/contrib/ConsensusTree.hpp ./src/tree-parse/TreeProcessor.hpp ./src/tree-parse/BasicTreeReader.cpp ./src/tree-parse/LabelPolicy.hpp ./src/tree-parse/TreeProcessor.cpp ./src/tree-parse/BasicTreeReader.hpp ./src/tree-parse/BranchLengthPolicy.hpp ./src/parameters/DivergenceRates.hpp ./src/parameters/RateHetParameter.hpp ./src/parameters/AbstractParameter.cpp ./src/parameters/TopologyParameter.cpp ./src/parameters/DivergenceTimes.hpp ./src/parameters/ParameterContent.cpp ./src/parameters/ProtModelParameter.hpp ./src/parameters/RateHetParameter.cpp ./src/parameters/BranchLengthsParameter.cpp ./src/parameters/RevMatParameter.cpp ./src/parameters/ProtModelParameter.cpp ./src/parameters/DivergenceTimes.cpp ./src/parameters/AbstractParameter.hpp ./src/parameters/TopologyParameter.hpp ./src/parameters/ParameterContent.hpp ./src/parameters/FrequencyParameter.hpp ./src/parameters/RevMatParameter.hpp ./src/parameters/BranchLengthsParameter.hpp ./src/parameters/FrequencyParameter.cpp ./src/parameters/DivergenceRates.cpp ./src/parameters/ParamAttribute.hpp ./src/proposals/NodeSlider.cpp ./src/proposals/ProposalType.cpp ./src/proposals/DivRateSlider.cpp ./src/proposals/AbstractProposal.cpp ./src/proposals/GenericTopoProposal.cpp ./src/proposals/InsertionResult.hpp ./src/proposals/GenericTopoProposal.hpp ./src/proposals/InsertionScore.hpp ./src/proposals/TreeLengthMultiplier.cpp ./src/proposals/ParameterProposal.cpp ./src/proposals/AminoModelJump.cpp ./src/proposals/ProposalSet.cpp ./src/proposals/ParameterProposal.hpp ./src/proposals/DistributionBranchLength.tpp ./src/proposals/MoveEnumeration.hpp ./src/proposals/BranchIntegrator.hpp ./src/proposals/DistributionBranchLength.hpp ./src/proposals/MoveEnumeration.cpp ./src/proposals/DivTimeProposal.cpp ./src/proposals/ChosenBranchIntegrator.hpp ./src/proposals/AbstractProposal.hpp ./src/proposals/BranchLengthMultiplier.hpp ./src/proposals/DivTimeSlider.hpp ./src/proposals/ProposalSet.hpp ./src/proposals/AminoModelJump.hpp ./src/proposals/DivRateSlider.hpp ./src/proposals/NodeSlider.hpp ./src/proposals/BranchLengthMultiplier.cpp ./src/proposals/DivTimeSlider.cpp ./src/proposals/DivTimeProposal.hpp ./src/proposals/TreeLengthMultiplier.hpp ./src/proposals/ProposalType.hpp ./src/proposals/topo-proposers/ParsSprProposer.hpp ./src/proposals/topo-proposers/TbrMove.hpp ./src/proposals/topo-proposers/MoveOptMode.hpp ./src/proposals/topo-proposers/SprMove.cpp ./src/proposals/topo-proposers/LikelihoodSprProposer.hpp ./src/proposals/topo-proposers/TopoMove.cpp ./src/proposals/topo-proposers/ExtendedSprProposer.cpp ./src/proposals/topo-proposers/ExtendedTbrProposer.hpp ./src/proposals/topo-proposers/TopoMove.hpp ./src/proposals/topo-proposers/ExtendedTbrProposer.cpp ./src/proposals/topo-proposers/MoveOptMode.cpp ./src/proposals/topo-proposers/LikelihoodSprProposer.cpp ./src/proposals/topo-proposers/ParsSprProposer.cpp ./src/proposals/topo-proposers/ExtendedSprProposer.hpp ./src/proposals/topo-proposers/StatNniProposer.cpp ./src/proposals/topo-proposers/TbrMove.cpp ./src/proposals/topo-proposers/StatNniProposer.hpp ./src/proposals/topo-proposers/TopoMoveProposer.hpp ./src/proposals/topo-proposers/SprMove.hpp ./src/proposals/param-proposers/MultiplierProposer.cpp ./src/proposals/param-proposers/SlidingProposer.hpp ./src/proposals/param-proposers/SlidingProposer.cpp ./src/proposals/param-proposers/RateSlidingProposer.cpp ./src/proposals/param-proposers/RateSlidingProposer.hpp ./src/proposals/param-proposers/AbstractProposer.hpp ./src/proposals/param-proposers/RateDirichletProposer.hpp ./src/proposals/param-proposers/MultiplierProposer.hpp ./src/proposals/param-proposers/DirichletProposer.cpp ./src/proposals/param-proposers/RateDirichletProposer.cpp ./src/proposals/param-proposers/DirichletProposer.hpp ./src/proposals/param-proposers/AbstractProposer.cpp ./src/file/DiagnosticsFile.cpp ./src/file/DiagnosticsFile.hpp ./src/file/TopologyFile.hpp ./src/file/ParameterFile.cpp ./src/file/OutputFile.cpp ./src/file/TopologyFile.cpp ./src/file/OutputFile.hpp ./src/file/ParameterFile.hpp ./src/model/ProtModel.hpp ./src/model/InternalBranchLength.cpp ./src/model/Category.hpp ./src/model/TreeAln.hpp ./src/model/DnaAlphabet.hpp ./src/model/BranchLengths.cpp ./src/model/AbstractAlphabet.cpp ./src/model/TreeAln.cpp ./src/model/Partition.hpp ./src/model/NodeAge.hpp ./src/model/BranchLength.hpp ./src/model/BranchPlain.cpp ./src/model/ProtModel.cpp ./src/model/NodeAge.cpp ./src/model/BranchLengths.hpp ./src/model/InternalBranchLength.hpp ./src/model/BranchLengthResource.hpp ./src/model/BinaryAlphabet.hpp ./src/model/BranchPlain.hpp ./src/model/RateHelper.hpp ./src/model/Partition.cpp ./src/model/BranchLengthResource.cpp ./src/model/RateHelper.cpp ./src/model/Category.cpp ./src/model/AbstractAlphabet.hpp ./src/model/BranchLength.cpp ./src/model/AminoAcidAlphabet.hpp ./src/data-struct/BipartitionHash.hpp ./src/data-struct/BipartitionHash.cpp ./src/data-struct/Path.hpp ./src/data-struct/Bipartition.hpp ./src/data-struct/Bipartition.cpp ./src/data-struct/Path.cpp ./src/priors/DirichletPrior.cpp ./src/priors/FixedPrior.cpp ./src/priors/UniformPrior.hpp ./src/priors/PriorBelief.hpp ./src/priors/PriorBelief.cpp ./src/priors/UniformPrior.cpp ./src/priors/AbstractPrior.hpp ./src/priors/DiscreteModelPrior.cpp ./src/priors/FixedPrior.hpp ./src/priors/ExponentialPrior.hpp ./src/priors/ExponentialPrior.cpp ./src/priors/DirichletPrior.hpp ./src/priors/DiscreteModelPrior.hpp
libcommdummy_a_SOURCES= ./src/comm/dummy/CommMethods.hpp ./src/comm/dummy/PendingSwapImpl.cpp ./src/comm/dummy/RemoteCommImpl.hpp ./src/comm/dummy/RemoteCommImpl.tpp ./src/comm/dummy/CommRequestImpl.cpp ./src/comm/dummy/RemoteCommImpl.cpp ./src/comm/dummy/PendingSwapImpl.hpp ./src/comm/dummy/CommRequestImpl.hpp ./src/comm/RemoteComm.cpp ./src/comm/AbstractPendingSwap.hpp ./src/comm/CommFlag.hpp ./src/comm/LocalComm.hpp ./src/comm/SwapElem.hpp ./src/comm/ParallelSetup.hpp ./src/comm/LocalComm.tpp ./src/comm/SwapElem.cpp ./src/comm/CommCore.hpp ./src/comm/IncompleteMesh.cpp ./src/comm/RemoteComm.hpp ./src/comm/LocalComm.cpp ./src/comm/PendingSwap.hpp ./src/comm/Communicator.cpp ./src/comm/Communicator.hpp ./src/comm/LocalSwap.hpp ./src/comm/PendingSwap.cpp ./src/comm/ParallelSetup.cpp ./src/comm/Communicator.tpp ./src/comm/CommRequest.hpp ./src/comm/IncompleteMesh.hpp ./src/comm/CommCoreNew.hpp ./src/comm/LocalSwap.cpp ./src/comm/CommRequest.cpp ./src/comm/CommCommon.hpp ./src/comm/threads/MessageQueueSingle.hpp ./src/comm/threads/ThreadResource.hpp ./src/comm/threads/MessageQueue.tpp ./src/comm/threads/MessageQueueSingle.cpp ./src/comm/threads/threadDefs.hpp ./src/comm/threads/ThreadResource.cpp ./src/comm/threads/MessageQueue.hpp ./src/comm/threads/MessageQueueSingle.tpp ./src/comm/threads/MessageQueue.cpp
libcommmpi_a_SOURCES= ./src/comm/mpi/PendingSwapImpl.cpp ./src/comm/mpi/RemoteCommImpl.hpp ./src/comm/mpi/RemoteCommImpl.tpp ./src/comm/mpi/CommRequestImpl.cpp ./src/comm/mpi/RemoteCommImpl.cpp ./src/comm/mpi/MpiType.hpp ./src/comm/mpi/MpiType.cpp ./src/comm/mpi/PendingSwapImpl.hpp ./src/comm/mpi/CommRequestImpl.hpp ./src/comm/RemoteComm.cpp ./src/comm/AbstractPendingSwap.hpp ./src/comm/CommFlag.hpp ./src/comm/LocalComm.hpp ./src/comm/SwapElem.hpp ./src/comm/ParallelSetup.hpp ./src/comm/LocalComm.tpp ./src/comm/SwapElem.cpp ./src/comm/CommCore.hpp ./src/comm/IncompleteMesh.cpp ./src/comm/RemoteComm.hpp ./src/comm/LocalComm.cpp ./src/comm/PendingSwap.hpp ./src/comm/Communicator.cpp ./src/comm/Communicator.hpp ./src/comm/LocalSwap.hpp ./src/comm/PendingSwap.cpp ./src/comm/ParallelSetup.cpp ./src/comm/Communicator.tpp ./src/comm/CommRequest.hpp ./src/comm/IncompleteMesh.hpp ./src/comm/CommCoreNew.hpp ./src/comm/LocalSwap.cpp ./src/comm/CommRequest.cpp ./src/comm/CommCommon.hpp ./src/comm/threads/MessageQueueSingle.hpp ./src/comm/threads/ThreadResource.hpp ./src/comm/threads/MessageQueue.tpp ./src/comm/threads/MessageQueueSingle.cpp ./src/comm/threads/threadDefs.hpp ./src/comm/threads/ThreadResource.cpp ./src/comm/threads/MessageQueue.hpp ./src/comm/threads/MessageQueueSingle.tpp ./src/comm/threads/MessageQueue.cpp
-libncl_a_SOURCES= ./lib/ncl-2.1.18/ncl/nxsmultiformat.h ./lib/ncl-2.1.18/ncl/nxsdiscretedatum.h ./lib/ncl-2.1.18/ncl/nxstaxaassociationblock.h ./lib/ncl-2.1.18/ncl/nxsutilcopy.h ./lib/ncl-2.1.18/ncl/nxsallocatematrix.h ./lib/ncl-2.1.18/ncl/nxscdiscretematrix.h ./lib/ncl-2.1.18/ncl/nxspublicblocks.h ./lib/ncl-2.1.18/ncl/nxsdistancedatum.h ./lib/ncl-2.1.18/ncl/nxsexception.h ./lib/ncl-2.1.18/ncl/nxsdistancesblock.h ./lib/ncl-2.1.18/ncl/nxsunalignedblock.h ./lib/ncl-2.1.18/ncl/nxstoken.h ./lib/ncl-2.1.18/ncl/nxstaxablock.h ./lib/ncl-2.1.18/ncl/nxsstring.h ./lib/ncl-2.1.18/ncl/nxssetreader.h ./lib/ncl-2.1.18/ncl/nxscharactersblock.h ./lib/ncl-2.1.18/ncl/nxscxxdiscretematrix.h ./lib/ncl-2.1.18/ncl/nxsdatablock.h ./lib/ncl-2.1.18/ncl/nxsblock.h ./lib/ncl-2.1.18/ncl/nxsassumptionsblock.h ./lib/ncl-2.1.18/ncl/nxsdefs.h ./lib/ncl-2.1.18/ncl/nxstreesblock.h ./lib/ncl-2.1.18/ncl/ncl.h ./lib/ncl-2.1.18/ncl/nxsreader.h ./lib/ncl-2.1.18/ncl/nxstoken.cpp ./lib/ncl-2.1.18/ncl/nxstaxaassociationblock.cpp ./lib/ncl-2.1.18/ncl/nxsassumptionsblock.cpp ./lib/ncl-2.1.18/ncl/nxsdatablock.cpp ./lib/ncl-2.1.18/ncl/nxsstring.cpp ./lib/ncl-2.1.18/ncl/nxsblock.cpp ./lib/ncl-2.1.18/ncl/nxspublicblocks.cpp ./lib/ncl-2.1.18/ncl/nxscxxdiscretematrix.cpp ./lib/ncl-2.1.18/ncl/nxstaxablock.cpp ./lib/ncl-2.1.18/ncl/nxstreesblock.cpp ./lib/ncl-2.1.18/ncl/nxsreader.cpp ./lib/ncl-2.1.18/ncl/nxssetreader.cpp ./lib/ncl-2.1.18/ncl/nxsmultiformat.cpp ./lib/ncl-2.1.18/ncl/nxsunalignedblock.cpp ./lib/ncl-2.1.18/ncl/nxscharactersblock.cpp ./lib/ncl-2.1.18/ncl/nxsexception.cpp ./lib/ncl-2.1.18/ncl/nxsdistancesblock.cpp
fix_latex_export.patch
do_not_require_missing_images.patch
fix_configure.ac.patch
debug.patch
version=4
opts="repacksuffix=+dfsg,dversionmangle=s/\+dfsg//g,repack,compression=xz" \
https://github.com/aberer/exabayes/releases .*/archive/v(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz)
/** @page LICENSE
Copyright 2010-2012, D. E. Shaw Research.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of D. E. Shaw Research nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
This diff is collapsed.
/**
@page CBRNG Counter Based RNGs (CBRNGs).
The counter-based random number generators (CBRNGs)
in the Random123 library are described in more detail in
<a href="http://dl.acm.org/citation.cfm?doid=2063405"><i>Parallel Random Numbers: As Easy as 1, 2, 3</i> </a>,
which was named the Best Paper at the ACM SC'11 International Conference on High Performance Computing, Networking,
Storage, and Analysis.
All the CBRNGs in the library conform to a consistent
interface. Basically:
\verbatim
value = CBRNGname(counter, key)
\endverbatim
Thus, with some care, they can be used
interchangeably in applications. (Since code
compiled with AES-NI instructions will result
in an illegal instruction exception on processors
without those instructions, Random123 provides a
@ref haveAESNI function that can be used
to detect the existence of AES at run-time;
user code could use it to either report an
error or substitute an alternative compatible
CBRNG.)
The API descriptions below are generic, but apply to
all the different @ref families "families" of
Random123 CBRNGs.
\section arrays Fixed-size Array Types
Data is passed into and back from the Random123 functions as
@ref arrayNxW "r123arrayNxW"
types; these types
contain fixed-size arrays of W-bit types (\c uintW_t for the
most part, but also a special r123m128i wrapper for the @ref
AESNI "ARS and AESNI" CBRNGs). The counter argument
and the return value have the same type,
referred to as \c ctr_type in C++, and \c ctr_t in C. The
type of the key argument is referred to as \c key_type in C++,
and \c key_t in C.
For an @ref arrayNxW "r123arrayNxW", \c r, the data member \c r.v is an array of N elements,
each of width W (each element is
type \c uintW_t or an r123m128i wrapper object).
C programs can access these elements as \c r.v[0], ... \c r.v[N-1] for
the \c uintW_t types.
In C++, these array types closely resemble the C++0x std::array<N, uintW_t> template, but do not
require C++0x libraries or compiler features.
C++ programs can access array elements via operator[]
\c r[0], ... \c r[N-1], or via most of the capabilities
of a C++ "Container" e.g. \c at(), \c begin(), \c end(),
\c size() and others. In addition, containers have <c> incr() </c> and <c> incr(unsigned long long)</c>
member function that do increment-with-carry, which facilitate
using r123arrays as very-long-period counters.
If the compiler environment supports it,
\c Random123/array.h also declares \c r123array1xm128i, which contains an array of one
\c r123m128i, which in turn is a class wrapping a single element
of \c __m128i SSE type, which can be accessed as \c r.v[0].m.
The @ref r123::ARS1xm128i_R RNGs
use \c r123array1xm128i for both \c ctr_type and \c key_type.
For the @ref AESNI "AESNI" RNG, \c ctr_type is an \c r123array1xm128i, but
\c key_type is an opaque type, which must be initialized
by assignment from a <c>userkey_type</c> (an r123array1xm128i).
\section aliasing A note on aliasing and type-punning
It is easiest (though not necessarily fastest) to choose a CBRNG whose
\c ctr_type matches the width of the random data needed by the
application, e.g., Philox4x32 for applications that need random data in
32-bit words. If the application's needs don't match the counter's value_type,
it is tempting to use "type punning" and pointer casts to interconvert between
types. Such conversions require great care and are very difficult to do
safely without use of unions or memcpy.
See <a
href="http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html">
here</a>
and
<a href="http://dbp-consulting.com/tutorials/StrictAliasing.html">
here</a>
for discussions of the pitfalls related to aliasing.
The C++
@ref r123::ReinterpretCtr template is a safe way to reinterpret \c CBRNG
counter types.
Gcc's \c
-Wstrict-aliasing=2 warning level will warn if strict aliasing
violations are detected. If you find yourself ignoring or disabling
warnings about strict aliasing, you should strongly consider adding something
like gcc's \c -fnostrict-aliasing option to your compiler
flags.
\section cxxapi C++ API
There are four families of CBRNGs in the library:
<ul>
<li> @ref ThreefryNxW "Threefry": @ref r123::Threefry2x32, @ref r123::Threefry4x32, @ref r123::Threefry2x64, @ref r123::Threefry4x64
<li> @ref PhiloxNxW "Philox": @ref r123::Philox2x32, @ref r123::Philox4x32, @ref r123::Philox2x64, @ref r123::Philox4x64
<li> @ref r123::AESNI4x32, r123::AESNI1xm128i
<li> @ref r123::ARS4x32_R
</ul>
A <i> counter based RNG </i> (CBRNG) with a name of the form
<i>FamilynameN</i>x<i>W</i> is a type G
with the three member typedefs:
<ul>
<li> G::ctr_type, which is an @ref arrayNxW "r123arrayNxW" container class.
<li> G::ukey_type, which is an @ref arrayNxW "r123arrayMxV" container class.
Note that the width, \c MxV of the key
may not be the same as the width \c NxW of
the ctr_type (@ref PhiloxNxW "Philox" keys are half as wide as the counter,
and future CBRNGs may well have different widths).
<li> G::key_type, which in most cases is identical to
G::ukey_type, but is different for the @ref AESNI "AESNI" types.
In all cases, there is a G::key_type(G::ukey_type) constructor
and a G::key_type assignment operator for a G::ukey_type
right-hand-side. In general, one can always write:
@code
G::ukey_type uk1, uk2;
// user code initializes uk1 and uk2
G::key_type k1(uk1), k2;
k2 = uk2;
@endcode
</ul>
For most CBRNG's, i.e., any one not in the @ref AESNI "AESNI" family, it is also
perfectly acceptable to set the elements of a G::key_type directly from application variables.
The quality of the results will not be compromised by using highly correlated
or "non-random" keys.
A value \c g of type \c G can be invoked as <c>g(c,k)</c>, where \c c
is a value of type \c G::ctr_type and \c k is a value of type \c G::key_type,
and <c>g(c,k)</c> returns a value of type \c G::ctr_type.
<ul>
<li> g() is a stateless, pure function. That is, g(c,k) may be called
any number of times in any context and always returns the same result
for the same inputs. In particular, c1==c2 and k1==k2 implies that g(c1,k1)
== g(c2,k2).
<li> For constant k, g(*,k) is a bijection. That is,
g(c1,k) == g(c2,k) if and only if c1 == c2.
<li> g "randomizes" its inputs. That is,
for most sequences of inputs (c1,k1),
(c2, k2), ... (including those obtained by following highly
regular patterns of incrementing and striding
through the counter and user key spaces) the output sequence, g(c1, k1),
g(c2, k2), ... looks like a a sequence of uniformly distributed
random variables drawn from the set of all ctr_types.
</ul>
All the CBRNGs in the library work by iterating a randomization function for a specific number of \e rounds.
Too few rounds and the CBRNG is a poor (perhaps
catastrophically poor) random number generator. Too many rounds and time is wasted
with little or no improvement in the randomness of the output. Each of the CBRNGs
has a specific number of rounds which the authors believe is a reasonable compromise
between speed and quality. In all cases, the default number of rounds includes a margin
of safety above the minimum number of rounds that have passed all of the SmallCrush, Crush and BigCrush
tests in the <a href="http://www.iro.umontreal.ca/~simardr/testu01/tu01.html"> TestU01</a> suite.
Users may, however wish to employ a different numbers of rounds. Each of the above
classes is actually a typedef of a more general class with a template parameter that
specifies the number of rounds as <i>name</i>_rounds. The template classes all end in \c _R:
<ul>
<li> @ref ThreefryNxW "Threefry": @ref r123::Threefry2x32_R, @ref r123::Threefry4x32_R, @ref r123::Threefry2x64_R, @ref r123::Threefry4x64_R
<li> @ref PhiloxNxW "Philox": @ref r123::Philox2x32_R, @ref r123::Philox4x32_R, @ref r123::Philox2x64_R, @ref r123::Philox4x64_R
<li> @ref r123::AESNI4x32_R, r123::AESNI1xm128i_R
<li> @ref r123::ARS4x32_R
</ul>
\section capi C API
A subset of the C++ interface
is also directly usable by C programs. All header files may be
safely included in C files. The C API to each of the
supported RNGs consists of two typedefs, <i>name</i>_ctr_t,
<i>name</i>_key_t, two functions <i>name</i>() and <i>name</i>_R(), and
the enum <i>name</i>_rounds which specifies the recommended number of rounds.
<ul>
<li> <i>name</i>(c, k), performs the recommended number of rounds of the <i>name</i> CBRNG.
<li> <i>name_R</i>(R,c,k), performs an R-round version of the <i>name</i> CBRNG.
<i>name</i>(c,k) is equivalent to
<i>name</i>_R(<i>name</i>_rounds, c, k).
</ul>
The \c _R functions are designed and implemented so that an optimizing compiler can achieve good performance
when the number of rounds is a compile-time constant. It is likely that <c>philox4x32_R(10,c,k) </c>
will perform much better than <c>philox4x32_R(r,c,k)</c> if \c r cannot be
evaluated at compile-time.
The supported names for the C API are
<ul>
<li> @ref ThreefryNxW "threefry": @ref threefry2x32, @ref threefry4x32, @ref threefry2x64, @ref threefry4x64.
<li> @ref PhiloxNxW "philox": @ref philox2x32, @ref philox4x32, @ref philox2x64, @ref philox4x64.
<li> @ref ars4x32_R, @ref ars1xm128i_R
<li> @ref aesni4x32, @ref aesni1xm128i
</ul>
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>$title</title>
<link href="$relpath$tabs.css" rel="stylesheet" type="text/css"/>
<link href="$relpath$search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="$relpath$search/search.js"></script>
<link href="$relpath$doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">$projectname $projectnumber Documentation</li></ul></div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Counter Based RNGs (CBRNGs).</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<h1>Counter Based RNGs (CBRNGs). </h1> </div>
</div>
<div class="contents">
<p>The counter-based random number generators (CBRNGs) in the Random123 library are described in more detail in <a href="http://dl.acm.org/citation.cfm?doid=2063405"><em>Parallel Random Numbers: As Easy as 1, 2, 3</em> </a>, which was named the Best Paper at the ACM SC'11 International Conference on High Performance Computing, Networking, Storage, and Analysis. All the CBRNGs in the library conform to a consistent interface. Basically: </p>
<div class="fragment"><pre class="fragment">
value = CBRNGname(counter, key)
</pre></div><p>Thus, with some care, they can be used interchangeably in applications. (Since code compiled with AES-NI instructions will result in an illegal instruction exception on processors without those instructions, Random123 provides a <a class="el" href="sse_8h.html#a0b35a046e85316295476d7d552411044">haveAESNI</a> function that can be used to detect the existence of AES at run-time; user code could use it to either report an error or substitute an alternative compatible CBRNG.)</p>
<p>The API descriptions below are generic, but apply to all the different <a class="el" href="index.html#families">families</a> of Random123 CBRNGs.</p>
<h2><a class="anchor" id="arrays"></a>
Fixed-size Array Types</h2>
<p>Data is passed into and back from the Random123 functions as <a class="el" href="group__arrayNxW.html">r123arrayNxW</a> types; these types contain fixed-size arrays of W-bit types (<code>uintW_t</code> for the most part, but also a special <a class="el" href="structr123m128i.html">r123m128i</a> wrapper for the <a class="el" href="group__AESNI.html">ARS and AESNI</a> CBRNGs). The counter argument and the return value have the same type, referred to as <code>ctr_type</code> in C++, and <code>ctr_t</code> in C. The type of the key argument is referred to as <code>key_type</code> in C++, and <code>key_t</code> in C. For an <a class="el" href="group__arrayNxW.html">r123arrayNxW</a>, <code>r</code>, the data member <code>r.v</code> is an array of N elements, each of width W (each element is type <code>uintW_t</code> or an <a class="el" href="structr123m128i.html">r123m128i</a> wrapper object). C programs can access these elements as <code>r.v</code>[0], ... <code>r.v</code>[N-1] for the <code>uintW_t</code> types.</p>
<p>In C++, these array types closely resemble the C++0x std::array&lt;N, uintW_t&gt; template, but do not require C++0x libraries or compiler features. C++ programs can access array elements via operator[] <code>r</code>[0], ... <code>r</code>[N-1], or via most of the capabilities of a C++ "Container" e.g. <code>at()</code>, <code>begin()</code>, <code>end()</code>, <code>size()</code> and others. In addition, containers have <code> incr() </code> and <code> incr(unsigned long long)</code> member function that do increment-with-carry, which facilitate using r123arrays as very-long-period counters.</p>
<p>If the compiler environment supports it, <code><a class="el" href="array_8h.html">Random123/array.h</a></code> also declares <code><a class="el" href="structr123array1xm128i.html">r123array1xm128i</a></code>, which contains an array of one <code><a class="el" href="structr123m128i.html">r123m128i</a></code>, which in turn is a class wrapping a single element of <code>__m128i</code> SSE type, which can be accessed as <code>r.v</code>[0].m. The <a class="el" href="structr123_1_1ARS1xm128i__R.html">r123::ARS1xm128i_R</a> RNGs use <code><a class="el" href="structr123array1xm128i.html">r123array1xm128i</a></code> for both <code>ctr_type</code> and <code>key_type</code>. For the <a class="el" href="group__AESNI.html">AESNI</a> RNG, <code>ctr_type</code> is an <code><a class="el" href="structr123array1xm128i.html">r123array1xm128i</a></code>, but <code>key_type</code> is an opaque type, which must be initialized by assignment from a <code>userkey_type</code> (an <a class="el" href="structr123array1xm128i.html">r123array1xm128i</a>).</p>
<h2><a class="anchor" id="aliasing"></a>
A note on aliasing and type-punning</h2>
<p>It is easiest (though not necessarily fastest) to choose a CBRNG whose <code>ctr_type</code> matches the width of the random data needed by the application, e.g., Philox4x32 for applications that need random data in 32-bit words. If the application's needs don't match the counter's value_type, it is tempting to use "type punning" and pointer casts to interconvert between types. Such conversions require great care and are very difficult to do safely without use of unions or memcpy. See <a href="http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html">here</a> and <a href="http://dbp-consulting.com/tutorials/StrictAliasing.html">here</a> for discussions of the pitfalls related to aliasing. The C++ <a class="el" href="structr123_1_1ReinterpretCtr.html">r123::ReinterpretCtr</a> template is a safe way to reinterpret <code>CBRNG</code> counter types. Gcc's <code>-Wstrict-aliasing=2</code> warning level will warn if strict aliasing violations are detected. If you find yourself ignoring or disabling warnings about strict aliasing, you should strongly consider adding something like gcc's <code>-fnostrict-aliasing</code> option to your compiler flags.</p>
<h2><a class="anchor" id="cxxapi"></a>
C++ API</h2>
<p>There are four families of CBRNGs in the library: </p>
<ul>
<li>
<a class="el" href="group__ThreefryNxW.html">Threefry</a>: <a class="el" href="group__ThreefryNxW.html#ga1c32939b65f84966c93677f4382ea36d">r123::Threefry2x32</a>, <a class="el" href="group__ThreefryNxW.html#gacb09a2dcfb7389769f0c58f45f132aaa">r123::Threefry4x32</a>, <a class="el" href="group__ThreefryNxW.html#ga2b54dd1b0d20f09239be5f8757f1f3db">r123::Threefry2x64</a>, <a class="el" href="group__ThreefryNxW.html#gae17c98bddf067365508ed0717f865e8b">r123::Threefry4x64</a> </li>
<li>
<a class="el" href="group__PhiloxNxW.html">Philox</a>: <a class="el" href="group__PhiloxNxW.html#ga81659a3ee5a1ca9e2e85c5d725a1ea4f">r123::Philox2x32</a>, <a class="el" href="group__PhiloxNxW.html#gaafd54060af05012db410034e3c0ecdc4">r123::Philox4x32</a>, <a class="el" href="group__PhiloxNxW.html#ga616a669079ac25119353416c14d46426">r123::Philox2x64</a>, <a class="el" href="group__PhiloxNxW.html#ga7776f4d481b7c0ac00db70272a1c77f0">r123::Philox4x64</a> </li>
<li>
<a class="el" href="structr123_1_1AESNI4x32.html">r123::AESNI4x32</a>, <a class="el" href="structr123_1_1AESNI1xm128i.html">r123::AESNI1xm128i</a> </li>
<li>
<a class="el" href="structr123_1_1ARS4x32__R.html">r123::ARS4x32_R</a> </li>
</ul>
<p>A <em> counter based RNG </em> (CBRNG) with a name of the form <em>FamilynameN</em>x<em>W</em> is a type G with the three member typedefs:</p>
<ul>
<li>
G::ctr_type, which is an <a class="el" href="group__arrayNxW.html">r123arrayNxW</a> container class. </li>
<li>
G::ukey_type, which is an <a class="el" href="group__arrayNxW.html">r123arrayMxV</a> container class. Note that the width, <code>MxV</code> of the key may not be the same as the width <code>NxW</code> of the ctr_type (<a class="el" href="group__PhiloxNxW.html">Philox</a> keys are half as wide as the counter, and future CBRNGs may well have different widths). </li>
<li>
G::key_type, which in most cases is identical to G::ukey_type, but is different for the <a class="el" href="group__AESNI.html">AESNI</a> types. In all cases, there is a G::key_type(G::ukey_type) constructor and a G::key_type assignment operator for a G::ukey_type right-hand-side. In general, one can always write: <div class="fragment"><pre class="fragment"> G::ukey_type uk1, uk2;
<span class="comment">// user code initializes uk1 and uk2</span>
G::key_type k1(uk1), k2;
k2 = uk2;
</pre></div> </li>
</ul>
<p>For most CBRNG's, i.e., any one not in the <a class="el" href="group__AESNI.html">AESNI</a> family, it is also perfectly acceptable to set the elements of a G::key_type directly from application variables. The quality of the results will not be compromised by using highly correlated or "non-random" keys.</p>
<p>A value <code>g</code> of type <code>G</code> can be invoked as <code>g(c,k)</code>, where <code>c</code> is a value of type <code>G::ctr_type</code> and <code>k</code> is a value of type <code>G::key_type</code>, and <code>g(c,k)</code> returns a value of type <code>G::ctr_type</code>.</p>
<ul>
<li>
g() is a stateless, pure function. That is, g(c,k) may be called any number of times in any context and always returns the same result for the same inputs. In particular, c1==c2 and k1==k2 implies that g(c1,k1) == g(c2,k2). </li>
<li>
For constant k, g(*,k) is a bijection. That is, g(c1,k) == g(c2,k) if and only if c1 == c2. </li>
<li>
g "randomizes" its inputs. That is, for most sequences of inputs (c1,k1), (c2, k2), ... (including those obtained by following highly regular patterns of incrementing and striding through the counter and user key spaces) the output sequence, g(c1, k1), g(c2, k2), ... looks like a a sequence of uniformly distributed random variables drawn from the set of all ctr_types. </li>
</ul>
<p>All the CBRNGs in the library work by iterating a randomization function for a specific number of <em>rounds</em>. Too few rounds and the CBRNG is a poor (perhaps catastrophically poor) random number generator. Too many rounds and time is wasted with little or no improvement in the randomness of the output. Each of the CBRNGs has a specific number of rounds which the authors believe is a reasonable compromise between speed and quality. In all cases, the default number of rounds includes a margin of safety above the minimum number of rounds that have passed all of the SmallCrush, Crush and BigCrush tests in the <a href="http://www.iro.umontreal.ca/~simardr/testu01/tu01.html">TestU01</a> suite.</p>
<p>Users may, however wish to employ a different numbers of rounds. Each of the above classes is actually a typedef of a more general class with a template parameter that specifies the number of rounds as <em>name</em>_rounds. The template classes all end in <code>_R:</code> </p>
<ul>
<li>
<a class="el" href="group__ThreefryNxW.html">Threefry</a>: <a class="el" href="structr123_1_1Threefry2x32__R.html">r123::Threefry2x32_R</a>, <a class="el" href="structr123_1_1Threefry4x32__R.html">r123::Threefry4x32_R</a>, <a class="el" href="structr123_1_1Threefry2x64__R.html">r123::Threefry2x64_R</a>, <a class="el" href="structr123_1_1Threefry4x64__R.html">r123::Threefry4x64_R</a> </li>
<li>
<a class="el" href="group__PhiloxNxW.html">Philox</a>: <a class="el" href="structr123_1_1Philox2x32__R.html">r123::Philox2x32_R</a>, <a class="el" href="structr123_1_1Philox4x32__R.html">r123::Philox4x32_R</a>, <a class="el" href="structr123_1_1Philox2x64__R.html">r123::Philox2x64_R</a>, <a class="el" href="structr123_1_1Philox4x64__R.html">r123::Philox4x64_R</a> </li>
<li>
<a class="el" href="structr123_1_1AESNI4x32__R.html">r123::AESNI4x32_R</a>, <a class="el" href="structr123_1_1AESNI1xm128i__R.html">r123::AESNI1xm128i_R</a> </li>
<li>
<a class="el" href="structr123_1_1ARS4x32__R.html">r123::ARS4x32_R</a> </li>
</ul>
<h2><a class="anchor" id="capi"></a>
C API</h2>
<p>A subset of the C++ interface is also directly usable by C programs. All header files may be safely included in C files. The C API to each of the supported RNGs consists of two typedefs, <em>name</em>_ctr_t, <em>name</em>_key_t, two functions <em>name</em>() and <em>name</em>_R(), and the enum <em>name</em>_rounds which specifies the recommended number of rounds. </p>
<ul>
<li>
<em>name</em>(c, k), performs the recommended number of rounds of the <em>name</em> CBRNG. </li>
<li>
<em>name_R</em>(R,c,k), performs an R-round version of the <em>name</em> CBRNG. <em>name</em>(c,k) is equivalent to <em>name</em>_R(<em>name</em>_rounds, c, k). </li>
</ul>
<p>The <code>_R</code> functions are designed and implemented so that an optimizing compiler can achieve good performance when the number of rounds is a compile-time constant. It is likely that <code>philox4x32_R(10,c,k) </code> will perform much better than <code>philox4x32_R(r,c,k)</code> if <code>r</code> cannot be evaluated at compile-time.</p>
<p>The supported names for the C API are </p>
<ul>
<li>
<a class="el" href="group__ThreefryNxW.html">threefry</a>: <a class="el" href="threefry_8h.html#af98f648fb8e458ff0c6825cb903734f2">threefry2x32</a>, <a class="el" href="threefry_8h.html#a1636cce9de54f919e8952a42b7f397fd">threefry4x32</a>, <a class="el" href="threefry_8h.html#aea6a4bd5c80354a4f575c9bec2702172">threefry2x64</a>, <a class="el" href="threefry_8h.html#a382d18a49002d2a5e2b2f06d58669d70">threefry4x64</a>. </li>
<li>
<a class="el" href="group__PhiloxNxW.html">philox</a>: <a class="el" href="philox_8h.html#ab2496424917f063a4990f01943a07fe0">philox2x32</a>, <a class="el" href="philox_8h.html#a432a3df828dd51acd0b7ec2fee1d4d7e">philox4x32</a>, <a class="el" href="philox_8h.html#ae6b57a71e4efa369cc19416fc088b5a5">philox2x64</a>, <a class="el" href="philox_8h.html#a62fb1b4d9775396303ebb2a801fea8e6">philox4x64</a>. </li>
<li>
<a class="el" href="group__AESNI.html#gab13b093252d4bb3389d27d4e3b04dae8">ars4x32_R</a>, <a class="el" href="group__AESNI.html#gaddc6efc2007f6f66ee914eb7074cff1e">ars1xm128i_R</a> </li>
<li>
<a class="el" href="group__AESNI.html#gae3950c524818b49d1cdfad481880a33a">aesni4x32</a>, <a class="el" href="group__AESNI.html#ga3ba5daca2d4d076ece24900084e71311">aesni1xm128i</a> </li>
</ul>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Random123/conventional/Engine.hpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> </div>
<div class="headertitle">
<h1>Random123/conventional/Engine.hpp File Reference</h1> </div>
</div>
<div class="contents">
<code>#include &quot;../features/compilerfeatures.h&quot;</code><br/>
<code>#include &quot;../array.h&quot;</code><br/>
<code>#include &lt;limits&gt;</code><br/>
<code>#include &lt;stdexcept&gt;</code><br/>
<code>#include &lt;sstream&gt;</code><br/>
<code>#include &lt;algorithm&gt;</code><br/>
<code>#include &lt;vector&gt;</code><br/>
<p><a href="Engine_8hpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structr123_1_1Engine.html">r123::Engine&lt; CBRNG &gt;</a></td></tr>
<tr><td colspan="2"><h2><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacer123.html">r123</a></td></tr>
</table>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Examples, Tests and Benchmarks</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<h1>Examples, Tests and Benchmarks </h1> </div>
</div>
<div class="contents">
<p>The examples/ directory contains tests, examples and timing harnesses for the components of the Random123 library.</p>
<h2><a class="anchor" id="building"></a>
Compiling and Running the code</h2>
<p>Installing and using Random123 requires only the use of the header files, and has no prerequisites other than a reasonable C99 or C++98 compiler.</p>
<p>With a modern GNU make (3.80 or newer), building and running the core tests and examples can be as easy as running gmake with no arguments. Note, though, that the provided examples/GNUmakefile intentionally avoids setting any of the standard make variables: CC, CXX, CPPFLAGS, CFLAGS, CXXFLAGS, TARGET_ARCH, LDFLAGS, LOADLIBES, LDLIBS. GNU make will inherit settings for these variables from the environment, or they may be set on the command line. If none are set, compilation will proceed using system-wide default flags, generally without advanced optimization, architectural tuning, warnings, or other common options.</p>
<p>Before putting the Random123 library to use in an application, it is important to test it using the same compiler flags and features that the application will use. In other words, the conventional make variables should be set the same way when testing the library as they will be set when the library is actually compiled into your application. Something like: </p>
<div class="fragment"><pre class="fragment">gmake CFLAGS=<span class="stringliteral">&quot;-std=c99&quot;</span> CXXFLAGS=<span class="stringliteral">&quot;-std=c++0x&quot;</span> CPPFLAGS=<span class="stringliteral">&quot;/alternate/location/include -O3 -Wall -Wstrict-aliasing=2&quot;</span> TARGET_ARCH=<span class="stringliteral">&quot;-march=native&quot;</span>
</pre></div><p> would confirm that all is well with optimization on, and output targeted at an architecture with the same capabilities as the machine running the compilation.</p>
<p>Very old versions of GNU make (pre-2002) or non-GNU make will not work with examples/GNUmakefile.. Lacking a suitably modern GNU make, our advice is to invoke the C or C++ compiler directly on the source files in the examples/ directory. The <a href="file:">file:</a> examples/BUILD.LOG contains a list of sample build commands. They will almost certainly need to be adapted to the target system. For Windows users, BUILDVC.BAT invokes the Microsoft Visual Studio compiler. Edit it as needed for your platform.</p>
<h2><a class="anchor" id="tests"></a>
Tests</h2>
<p>It is recommended that Random123 be tested <b> on the target system, with the target compiler, intended optimization levels, options, target architectures, etc.</b> before relying it. The library uses architecture- and compiler-specific intrinsics, features and assembly language. We have seen cases where one compiler (open64 version 4.2.4) masquerades as another compiler (it defines __GNUC__) accepts extensions specific to the other compiler (__uint128_t) without error or warning, and then silently produces incorrect code. The only way to guard against this kind of misbehavior is to compile and run the tests with the compiler and options that you intend to use and the platform that you intend to run on.</p>
<h3><a class="anchor" id="kat"></a>
Known Answer Tests</h3>
<p>Testing that your compiled code computes the same "Known Answers" as the reference implementation which has been subjected to the Crush batteries of statistical tests is critically important.</p>
<p>The file <code>examples/kat_vectors</code> contains a few thousand "Known Answer
Test" vectors, i.e., tuples of (method, counter, key, answer). The source file katc.c is incorporated into kat_c.c (C), kat_cpp.cpp (C++), kat_cuda.cu (CUDA) and kat_opencl.c (OpenCL), which are compiled into kat_c, kat_cpp, kat_cuda and kat_opencl, respectively. Each of these will read kat_vectors and verify that the compiled code obtains the same "known answers".</p>
<p>The kat vectors are not language-specific. Implementations of CBRNGs in other languages could also be validated against <code>kat_vectors</code>. The kat vectors are also byte-order independent. In other words, the CBRNGs in the library should produce the same numerical results on little-endian and big-endian hardware, but this behavior is largely untested.</p>
<h3><a class="anchor" id="ut"></a>
Unit Tests</h3>
<p>examples/ also contains tests of specific components of the library. While not exhaustive, these tests verify that a variety of invariants are satisfied by the public methods (e.g., that incr(N) is the same as incr() N times). They also serve to verify some of the compile-time feature-test logic which, if incorrect can lead to mysterious errors (e.g., is it necessary to <code>include &lt;smmintrin.h&gt;</code>). Unit tests include:</p>
<ul>
<li>
ut_features - verifies compile-time feature-test logic. </li>
<li>
ut_carray - verifies the capabilities of the <a class="el" href="group__arrayNxW.html">r123arrayNxW</a> types. </li>
<li>
ut_M128 - verifies the capabilities of the <a class="el" href="structr123m128i.html">r123m128i</a> type (only when SSE2 is available). </li>
<li>
ut_ReinterpretCtr - verifies the <a class="el" href="structr123_1_1ReinterpretCtr.html">r123::ReinterpretCtr</a> wrapper template. </li>
<li>
ut_Engine - verifies the capabilities of the <a class="el" href="structr123_1_1Engine.html">r123::Engine</a> wrapper template. </li>
<li>
ut_aes - verifies that the <a class="el" href="group__AESNI.html">AESNI</a> cbrngs match known answers from FIPS-197. </li>
<li>
ut_gsl - tests the <a class="el" href="gsl__cbrng_8h.html#af561a004eef8e93cdfd6b255a8a1eb75">GSL_CBRNG</a> adapter <b>Requires the GNU Scientific Library</b>. </li>
</ul>
<h2><a class="anchor" id="examples"></a>
Examples</h2>
<h3><a class="anchor" id="simple"></a>
Simple examples in C and C++</h3>
<p>There are two extremely short examples that show all the code necessary to obtain and print a few random numbers in C and C++: </p>
<ul>
<li>
simple.c </li>
<li>
simplepp.cpp </li>
</ul>
<h3><a class="anchor" id="generation"></a>
Generation of uniformly distributed real values.</h3>
<p>The uniformly distributed integers that the CBRNGs produce are rarely what is required by applications. Sampling other distributions is beyond the scope of Random123. Many distributions can be sampled with GSL (using &lt;<a class="el" href="gsl__cbrng_8h.html">Random123/conventional/gsl_cbrng.h</a>&gt; or with C++11's &lt;random&gt; (using &lt;<a class="el" href="MicroURNG_8hpp.html">Random123/MicroURNG.hpp</a>&gt; or &lt;<a class="el" href="Engine_8hpp.html">Random123/conventional/Engine.hpp</a>&gt;. Nevertheless, some distributions are so simple that the machinery of &lt;random&gt; or GSL seems like overkill. We provide code to generate uniformly distributed real numbers in the range (0, 1) and (-1, 1) in two header files: </p>
<ul>
<li>
uniform.hpp </li>
<li>
u01fixedpt.h </li>
</ul>
<p>We encourage you to copy these header files and use them (or modify them) to suit your needs. They are not as thoroughly tested or as portable as the headers in the library itself, but they should be safe to use on any platform with IEEE-754 floating point support. They are documented in comments in the files themselves.</p>
<h3><a class="anchor" id="pi"></a>
Estimating pi using different APIs</h3>
<p>Using random numbers to estimate pi is a classic example. The idea is to choose points at random in a square and to count how many of them lie within the inscribed circle. Since the area of the square is 4*r^2 and the area of the circle is pi*r^2, the ratio of the number of points in the circle to the total number of points should approach pi/4 as the number of points grows.</p>
<p>We give several examples of pi estimation, each of which illustrates a slightly different API</p>
<ul>
<li>
pi_capi - using only the basic C API </li>
<li>
pi_cppapi - using only the basic C++ API </li>
<li>
pi_u01 - using the C++ API and uniform.hpp </li>
<li>
pi_gsl - using a Random123 generator, but a gsl distribution to obtain real-valued random numbers. <b>Requires the GNU Scientific Library</b> </li>
<li>
pi_microurng - using a Random123 generator, but a C++0x &lt;random&gt; distribution to obtain real-valued random numbers </li>
<li>
pi_cuda - using the Random123 library with CUDA, runnable on an NVIDIA GPU </li>
<li>
pi_cudapp - using the C++ API with CUDA, runnable on an NVIDIA GPU </li>
<li>
pi_opencl - using the Random123 library with OpenCL, runnable on any OpenCL platform: e.g. NVIDIA or ATI GPUs or Intel or AMD CPUs. The actual compute kernel lives in the <code>pi_opencl_kernel.ocl</code> file and is transformed by <code>gencl.sh</code> into strings that get included in <code>pi_opencl.c</code>, since the OpenCL kernels get compiled for the target OpenCL platform at run-time </li>
<li>
pi_aes - uses the AESNI4x32 Random123 generator </li>
</ul>
<h2><a class="anchor" id="timers"></a>
Measuring performance</h2>
<p>We include some timing harnesses that can be used to measure the performance of these CBRNGs on various platforms. These timing harnesses report a cycles-per-byte (cpB) metric, which should be independent of clock-rate or number of cores, but depends on compilers and the architecture of the processor being run on. They also report aggregate throughput in GB/sec: a more direct measure of performance, but one that depends on clock speed and number of cores being used. The timing harnesses are obscured by tricks required for portability across platforms and CBRNG type. As a result, they are not recommended as examples of the use of library and its APIs.</p>
<ul>
<li>
time_serial - uses the C API and reports performance for a single core. </li>
<li>
timers - uses the C++ API, and is the only tool that reports AESNI1xm128i and ARS1xm128i performance (if your CPU supports the AES-NI instruction extensions). </li>
<li>
time_thread - uses the C API and pthreads to report multithreaded performance, uses all cores available on the platform. </li>
<li>
time_cuda - uses the C API within NVIDIA CUDA to run on NVIDIA GPUs. </li>
<li>
time_opencl - uses the C API within OpenCL to run on GPUs or CPUs. </li>
</ul>
<p>time_serial, time_thread, time_cuda, time_opencl all use a common kernel defined in time_random123.h. They all use various util_* header files for utility functions and platform-related boilerplate (also used by the pi_* examples). </p>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: </title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="contents">
<p>Copyright 2010-2012, D. E. Shaw Research. All rights reserved.</p>
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
<p>Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.</p>
<p>Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.</p>
<p>Neither the name of D. E. Shaw Research nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.</p>
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </p>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Random123/MicroURNG.hpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> </div>
<div class="headertitle">
<h1>Random123/MicroURNG.hpp File Reference</h1> </div>
</div>
<div class="contents">
<code>#include &lt;stdexcept&gt;</code><br/>
<code>#include &lt;limits&gt;</code><br/>
<p><a href="MicroURNG_8hpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classr123_1_1MicroURNG.html">r123::MicroURNG&lt; CBRNG &gt;</a></td></tr>
<tr><td colspan="2"><h2><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacer123.html">r123</a></td></tr>
</table>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Random123/MicroURNG.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>Random123/MicroURNG.hpp</h1> </div>
</div>
<div class="contents">
<a href="MicroURNG_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">Copyright 2010-2011, D. E. Shaw Research.</span>
<a name="l00003"></a>00003 <span class="comment">All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">Redistribution and use in source and binary forms, with or without</span>
<a name="l00006"></a>00006 <span class="comment">modification, are permitted provided that the following conditions are</span>
<a name="l00007"></a>00007 <span class="comment">met:</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">* Redistributions of source code must retain the above copyright</span>
<a name="l00010"></a>00010 <span class="comment"> notice, this list of conditions, and the following disclaimer.</span>
<a name="l00011"></a>00011 <span class="comment"></span>
<a name="l00012"></a>00012 <span class="comment">* Redistributions in binary form must reproduce the above copyright</span>
<a name="l00013"></a>00013 <span class="comment"> notice, this list of conditions, and the following disclaimer in the</span>
<a name="l00014"></a>00014 <span class="comment"> documentation and/or other materials provided with the distribution.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment">* Neither the name of D. E. Shaw Research nor the names of its</span>
<a name="l00017"></a>00017 <span class="comment"> contributors may be used to endorse or promote products derived from</span>
<a name="l00018"></a>00018 <span class="comment"> this software without specific prior written permission.</span>
<a name="l00019"></a>00019 <span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00021"></a>00021 <span class="comment">&quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00022"></a>00022 <span class="comment">LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00023"></a>00023 <span class="comment">A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00024"></a>00024 <span class="comment">OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00025"></a>00025 <span class="comment">SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00026"></a>00026 <span class="comment">LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
<a name="l00027"></a>00027 <span class="comment">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
<a name="l00028"></a>00028 <span class="comment">THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00029"></a>00029 <span class="comment">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00030"></a>00030 <span class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00031"></a>00031 <span class="comment">*/</span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef __MicroURNG_dot_hpp__</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define __MicroURNG_dot_hpp__</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;limits&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="keyword">namespace </span>r123{
<a name="l00078"></a>00078 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CBRNG&gt;
<a name="l00079"></a><a class="code" href="classr123_1_1MicroURNG.html">00079</a> <span class="keyword">class </span><a class="code" href="classr123_1_1MicroURNG.html">MicroURNG</a>{
<a name="l00080"></a>00080 <span class="comment">// According to C++0x, a URNG requires only a result_type,</span>
<a name="l00081"></a>00081 <span class="comment">// operator()(), min() and max() methods. Everything else</span>
<a name="l00082"></a>00082 <span class="comment">// (ctr_type, key_type, reset() method, etc.) is &quot;value added&quot;</span>
<a name="l00083"></a>00083 <span class="comment">// for the benefit of users that &quot;know&quot; that they&#39;re dealing with</span>
<a name="l00084"></a>00084 <span class="comment">// a MicroURNG.</span>
<a name="l00085"></a>00085 <span class="keyword">public</span>:
<a name="l00086"></a><a class="code" href="classr123_1_1MicroURNG.html#ab0b3a77c9408dbcb2f9d6b5c67e9c3f7">00086</a> <span class="keyword">typedef</span> CBRNG cbrng_type;
<a name="l00087"></a><a class="code" href="classr123_1_1MicroURNG.html#ac55cddda8fe0808f922f39beee587b27">00087</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classr123_1_1MicroURNG.html#ac55cddda8fe0808f922f39beee587b27">BITS</a> = 32;
<a name="l00088"></a><a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">00088</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> cbrng_type::ctr_type ctr_type;
<a name="l00089"></a><a class="code" href="classr123_1_1MicroURNG.html#aef90e6157f360434342ad0df4ce5f364">00089</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> cbrng_type::key_type key_type;
<a name="l00090"></a><a class="code" href="classr123_1_1MicroURNG.html#a7e6fd93fec2fe138ee36b401ff376cfc">00090</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> cbrng_type::ukey_type ukey_type;
<a name="l00091"></a><a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">00091</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> ctr_type::value_type result_type;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 R123_STATIC_ASSERT( std::numeric_limits&lt;result_type&gt;::digits &gt;= <a class="code" href="classr123_1_1MicroURNG.html#ac55cddda8fe0808f922f39beee587b27">BITS</a>, <span class="stringliteral">&quot;The result_type must have at least 32 bits&quot;</span> );
<a name="l00094"></a>00094
<a name="l00095"></a><a class="code" href="classr123_1_1MicroURNG.html#a64cd4d33b4cab5d3d9c556db68407b77">00095</a> <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> <a class="code" href="classr123_1_1MicroURNG.html#a64cd4d33b4cab5d3d9c556db68407b77">operator()</a>(){
<a name="l00096"></a>00096 <span class="keywordflow">if</span>(last_elem == 0){
<a name="l00097"></a>00097 <span class="comment">// jam n into the high bits of c</span>
<a name="l00098"></a>00098 <span class="keyword">const</span> <span class="keywordtype">size_t</span> W = std::numeric_limits&lt;result_type&gt;::digits;
<a name="l00099"></a>00099 <a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> c = c0;
<a name="l00100"></a>00100 c[c0.size()-1] |= n&lt;&lt;(W-<a class="code" href="classr123_1_1MicroURNG.html#ac55cddda8fe0808f922f39beee587b27">BITS</a>);
<a name="l00101"></a>00101 rdata = b(c,k);
<a name="l00102"></a>00102 n++;
<a name="l00103"></a>00103 last_elem = rdata.size();
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 <span class="keywordflow">return</span> rdata[--last_elem];
<a name="l00106"></a>00106 }
<a name="l00107"></a><a class="code" href="classr123_1_1MicroURNG.html#a19afb80312c370e1670bf8afc73d802e">00107</a> <a class="code" href="classr123_1_1MicroURNG.html#a19afb80312c370e1670bf8afc73d802e">MicroURNG</a>(<a class="code" href="classr123_1_1MicroURNG.html#ab0b3a77c9408dbcb2f9d6b5c67e9c3f7">cbrng_type</a> _b, <a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> _c0, <a class="code" href="classr123_1_1MicroURNG.html#a7e6fd93fec2fe138ee36b401ff376cfc">ukey_type</a> _uk) : b(_b), c0(_c0), k(_uk), n(0), last_elem(0) {
<a name="l00108"></a>00108 chkhighbits();
<a name="l00109"></a>00109 }
<a name="l00110"></a><a class="code" href="classr123_1_1MicroURNG.html#a7ecf43819bc96804892a78c6715f587b">00110</a> <a class="code" href="classr123_1_1MicroURNG.html#a7ecf43819bc96804892a78c6715f587b">MicroURNG</a>(<a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> _c0, <a class="code" href="classr123_1_1MicroURNG.html#a7e6fd93fec2fe138ee36b401ff376cfc">ukey_type</a> _uk) : b(), c0(_c0), k(_uk), n(0), last_elem(0) {
<a name="l00111"></a>00111 chkhighbits();
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="comment">// _Min and _Max work around a bug in the library shipped with MacOS Xcode 4.5.2.</span>
<a name="l00115"></a>00115 <span class="comment">// See the commment in conventional/Engine.hpp. </span>
<a name="l00116"></a><a class="code" href="classr123_1_1MicroURNG.html#a1f2787f136a8a807d14eab8cb1ca8c14">00116</a> <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> <a class="code" href="classr123_1_1MicroURNG.html#a1f2787f136a8a807d14eab8cb1ca8c14">_Min</a> = 0;
<a name="l00117"></a><a class="code" href="classr123_1_1MicroURNG.html#a4faecd7ab54c7678ee66c413bb984bf0">00117</a> <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> <a class="code" href="classr123_1_1MicroURNG.html#a4faecd7ab54c7678ee66c413bb984bf0">_Max</a> = ~((result_type)0);
<a name="l00118"></a>00118
<a name="l00119"></a><a class="code" href="classr123_1_1MicroURNG.html#aa05c857c01053cf9185406d69757b101">00119</a> <span class="keyword">static</span> R123_CONSTEXPR <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> min <a class="code" href="classr123_1_1MicroURNG.html#aa05c857c01053cf9185406d69757b101">R123_NO_MACRO_SUBST</a> () { <span class="keywordflow">return</span> <a class="code" href="classr123_1_1MicroURNG.html#a1f2787f136a8a807d14eab8cb1ca8c14">_Min</a>; }
<a name="l00120"></a><a class="code" href="classr123_1_1MicroURNG.html#a3af623b6366d6e848d67d72e4b0f363c">00120</a> <span class="keyword">static</span> R123_CONSTEXPR <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> max <a class="code" href="classr123_1_1MicroURNG.html#a3af623b6366d6e848d67d72e4b0f363c">R123_NO_MACRO_SUBST</a> () { <span class="keywordflow">return</span> <a class="code" href="classr123_1_1MicroURNG.html#a4faecd7ab54c7678ee66c413bb984bf0">_Max</a>; }
<a name="l00121"></a>00121 <span class="comment">// extra methods:</span>
<a name="l00122"></a><a class="code" href="classr123_1_1MicroURNG.html#a30f52334b7cfcbe6d86870496ca57ea6">00122</a> <span class="keyword">const</span> <a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a>&amp; <a class="code" href="classr123_1_1MicroURNG.html#a30f52334b7cfcbe6d86870496ca57ea6">counter</a>()<span class="keyword"> const</span>{ <span class="keywordflow">return</span> c0; }
<a name="l00123"></a><a class="code" href="classr123_1_1MicroURNG.html#add2f214254ddc2291e3b2c8b5dbe791a">00123</a> <span class="keywordtype">void</span> <a class="code" href="classr123_1_1MicroURNG.html#add2f214254ddc2291e3b2c8b5dbe791a">reset</a>(<a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> _c0, <a class="code" href="classr123_1_1MicroURNG.html#a7e6fd93fec2fe138ee36b401ff376cfc">ukey_type</a> _uk){
<a name="l00124"></a>00124 c0 = _c0;
<a name="l00125"></a>00125 chkhighbits();
<a name="l00126"></a>00126 k = _uk;
<a name="l00127"></a>00127 n = 0;
<a name="l00128"></a>00128 last_elem = 0;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keyword">private</span>:
<a name="l00132"></a>00132 <a class="code" href="classr123_1_1MicroURNG.html#ab0b3a77c9408dbcb2f9d6b5c67e9c3f7">cbrng_type</a> b;
<a name="l00133"></a>00133 <a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> c0;
<a name="l00134"></a>00134 <a class="code" href="classr123_1_1MicroURNG.html#aef90e6157f360434342ad0df4ce5f364">key_type</a> k;
<a name="l00135"></a>00135 R123_ULONG_LONG n;
<a name="l00136"></a>00136 <span class="keywordtype">size_t</span> last_elem;
<a name="l00137"></a>00137 <a class="code" href="classr123_1_1MicroURNG.html#a5aba882fd21e4d8f1a445f546e1e4476">ctr_type</a> rdata;
<a name="l00138"></a>00138 <span class="keywordtype">void</span> chkhighbits(){
<a name="l00139"></a>00139 <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> r = c0[c0.size()-1];
<a name="l00140"></a>00140 <a class="code" href="classr123_1_1MicroURNG.html#a512957c3e7b3d22741ef0a436b973c2b">result_type</a> mask = ((uint64_t)std::numeric_limits&lt;result_type&gt;::max <a class="code" href="classr123_1_1MicroURNG.html#aa05c857c01053cf9185406d69757b101">R123_NO_MACRO_SUBST</a> ())&gt;&gt;<a class="code" href="classr123_1_1MicroURNG.html#ac55cddda8fe0808f922f39beee587b27">BITS</a>;
<a name="l00141"></a>00141 <span class="keywordflow">if</span>((r&amp;mask) != r)
<a name="l00142"></a>00142 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">&quot;MicroURNG: c0, does not have high bits clear&quot;</span>);
<a name="l00143"></a>00143 }
<a name="l00144"></a>00144 };
<a name="l00145"></a>00145 } <span class="comment">// namespace r123</span>
<a name="l00146"></a>00146 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: examples/README File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<h1>examples/README File Reference</h1> </div>
</div>
<div class="contents">
<table class="memberdecls">
</table>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Random123/ReinterpretCtr.hpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> </div>
<div class="headertitle">
<h1>Random123/ReinterpretCtr.hpp File Reference</h1> </div>
</div>
<div class="contents">
<code>#include &quot;<a class="el" href="compilerfeatures_8h_source.html">features/compilerfeatures.h</a>&quot;</code><br/>
<code>#include &lt;cstring&gt;</code><br/>
<p><a href="ReinterpretCtr_8hpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structr123_1_1ReinterpretCtr.html">r123::ReinterpretCtr&lt; ToType, CBRNG &gt;</a></td></tr>
<tr><td colspan="2"><h2><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacer123.html">r123</a></td></tr>
</table>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Random123-1.08: Random123/ReinterpretCtr.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<div class="tabs"><ul class="tablist"><li style="padding-left: 1.5em; font-weight: bold">Random123-1.08 Documentation</li></ul></div>
<!-- Generated by Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>Random123/ReinterpretCtr.hpp</h1> </div>
</div>
<div class="contents">
<a href="ReinterpretCtr_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">Copyright 2010-2011, D. E. Shaw Research.</span>
<a name="l00003"></a>00003 <span class="comment">All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">Redistribution and use in source and binary forms, with or without</span>
<a name="l00006"></a>00006 <span class="comment">modification, are permitted provided that the following conditions are</span>
<a name="l00007"></a>00007 <span class="comment">met:</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">* Redistributions of source code must retain the above copyright</span>
<a name="l00010"></a>00010 <span class="comment"> notice, this list of conditions, and the following disclaimer.</span>
<a name="l00011"></a>00011 <span class="comment"></span>
<a name="l00012"></a>00012 <span class="comment">* Redistributions in binary form must reproduce the above copyright</span>
<a name="l00013"></a>00013 <span class="comment"> notice, this list of conditions, and the following disclaimer in the</span>
<a name="l00014"></a>00014 <span class="comment"> documentation and/or other materials provided with the distribution.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment">* Neither the name of D. E. Shaw Research nor the names of its</span>
<a name="l00017"></a>00017 <span class="comment"> contributors may be used to endorse or promote products derived from</span>
<a name="l00018"></a>00018 <span class="comment"> this software without specific prior written permission.</span>
<a name="l00019"></a>00019 <span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00021"></a>00021 <span class="comment">&quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00022"></a>00022 <span class="comment">LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00023"></a>00023 <span class="comment">A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00024"></a>00024 <span class="comment">OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00025"></a>00025 <span class="comment">SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00026"></a>00026 <span class="comment">LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
<a name="l00027"></a>00027 <span class="comment">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
<a name="l00028"></a>00028 <span class="comment">THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00029"></a>00029 <span class="comment">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00030"></a>00030 <span class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00031"></a>00031 <span class="comment">*/</span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef __ReinterpretCtr_dot_hpp__</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define __ReinterpretCtr_dot_hpp__</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="compilerfeatures_8h.html">features/compilerfeatures.h</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;cstring&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="keyword">namespace </span>r123{
<a name="l00053"></a>00053 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ToType, <span class="keyword">typename</span> CBRNG&gt;
<a name="l00054"></a><a class="code" href="structr123_1_1ReinterpretCtr.html">00054</a> <span class="keyword">struct </span><a class="code" href="structr123_1_1ReinterpretCtr.html">ReinterpretCtr</a>{
<a name="l00055"></a><a class="code" href="structr123_1_1ReinterpretCtr.html#a26cf9e933b35411c37070c948085ba02">00055</a> <span class="keyword">typedef</span> ToType ctr_type;
<a name="l00056"></a><a class="code" href="structr123_1_1ReinterpretCtr.html#a470b21676ed709aa9d9ad524a67410f1">00056</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> CBRNG::key_type key_type;
<a name="l00057"></a><a class="code" href="structr123_1_1ReinterpretCtr.html#ae0accaee618b5eb28a24acd516b3a4c6">00057</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> CBRNG::ctr_type bctype;
<a name="l00058"></a><a class="code" href="structr123_1_1ReinterpretCtr.html#a4b0b69c1aa58d62bb22e51e16c586bee">00058</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> CBRNG::ukey_type ukey_type;
<a name="l00059"></a>00059 R123_STATIC_ASSERT(<span class="keyword">sizeof</span>(ToType) == <span class="keyword">sizeof</span>(<a class="code" href="structr123_1_1ReinterpretCtr.html#ae0accaee618b5eb28a24acd516b3a4c6">bctype</a>) &amp;&amp; <span class="keyword">sizeof</span>(<span class="keyword">typename</span> bctype::value_type) != 16,
<a name="l00060"></a>00060 <span class="stringliteral">&quot;ReinterpretCtr: sizeof(ToType) is not the same as sizeof(CBRNG::ctr_type) or CBRNG::ctr_type::value_type looks like it might be __m128i&quot;</span>);
<a name="l00061"></a>00061 <span class="comment">// It&#39;s amazingly difficult to safely do conversions with __m128i.</span>
<a name="l00062"></a>00062 <span class="comment">// If we use the operator() implementation below with a CBRNG</span>
<a name="l00063"></a>00063 <span class="comment">// whose ctr_type is r123array1xm128i, gcc4.6 optimizes away the</span>
<a name="l00064"></a>00064 <span class="comment">// memcpys, inlines the operator()(c,k), and produces assembly</span>
<a name="l00065"></a>00065 <span class="comment">// language that ends with an aesenclast instruction with a</span>
<a name="l00066"></a>00066 <span class="comment">// destination operand pointing to an unaligned memory address ...</span>
<a name="l00067"></a>00067 <span class="comment">// Segfault! See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50444</span>
<a name="l00068"></a>00068 <span class="comment">// MSVC also produces code that crashes. We suspect a</span>
<a name="l00069"></a>00069 <span class="comment">// similar mechanism but haven&#39;t done the debugging necessary to</span>
<a name="l00070"></a>00070 <span class="comment">// be sure. We were able to &#39;fix&#39; gcc4.6 by making bc a mutable</span>
<a name="l00071"></a>00071 <span class="comment">// data member rather than declaring it in the scope of</span>
<a name="l00072"></a>00072 <span class="comment">// operator(). That didn&#39;t fix the MSVC problems, though.</span>
<a name="l00073"></a>00073 <span class="comment">//</span>
<a name="l00074"></a>00074 <span class="comment">// Conclusion - don&#39;t touch __m128i, at least for now. The</span>
<a name="l00075"></a>00075 <span class="comment">// easiest (but highly imprecise) way to do that is the static</span>
<a name="l00076"></a>00076 <span class="comment">// assertion above that rejects bctype::value_types of size 16. -</span>
<a name="l00077"></a>00077 <span class="comment">// Sep 2011.</span>
<a name="l00078"></a><a class="code" href="structr123_1_1ReinterpretCtr.html#a91edc5103397372cc5509ad17c0fc83a">00078</a> <a class="code" href="structr123_1_1ReinterpretCtr.html#a26cf9e933b35411c37070c948085ba02">ctr_type</a> <a class="code" href="structr123_1_1ReinterpretCtr.html#a91edc5103397372cc5509ad17c0fc83a">operator()</a>(<a class="code" href="structr123_1_1ReinterpretCtr.html#a26cf9e933b35411c37070c948085ba02">ctr_type</a> c, <a class="code" href="structr123_1_1ReinterpretCtr.html#a470b21676ed709aa9d9ad524a67410f1">key_type</a> k){
<a name="l00079"></a>00079 <a class="code" href="structr123_1_1ReinterpretCtr.html#ae0accaee618b5eb28a24acd516b3a4c6">bctype</a> bc;
<a name="l00080"></a>00080 std::memcpy(&amp;bc, &amp;c, <span class="keyword">sizeof</span>(c));
<a name="l00081"></a>00081 CBRNG b;
<a name="l00082"></a>00082 bc = b(bc, k);
<a name="l00083"></a>00083 std::memcpy(&amp;c, &amp;bc, <span class="keyword">sizeof</span>(bc));
<a name="l00084"></a>00084 <span class="keywordflow">return</span> c;
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 };
<a name="l00087"></a>00087 } <span class="comment">// namespace r123</span>
<a name="l00088"></a>00088 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&nbsp;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Tue Aug 20 2013 13:08:22 for Random123-1.08 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>