Quinoa all test code coverage report
Current view: top level - RNGTest - TestU01Wrappers.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 15 17 88.2 %
Date: 2021-11-11 18:25:50 Functions: 18 39 46.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 24 25.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/RNGTest/TestU01Wrappers.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     TestU01 global-scope wrappers
       9                 :            :   \details   TestU01 global-scope wrappers. For more info on why these functions
      10                 :            :     are in global-scope, see Main/RNGTest.C, for more info on why they are
      11                 :            :     static inline, see http://stackoverflow.com/a/9399539.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef TestU01Wrappers_h
      15                 :            : #define TestU01Wrappers_h
      16                 :            : 
      17                 :            : #include <map>
      18                 :            : 
      19                 :            : #include "RNG.hpp"
      20                 :            : 
      21                 :            : namespace rngtest {
      22                 :            : 
      23                 :            : extern std::map< tk::ctr::RawRNGType, tk::RNG > g_rng;
      24                 :            : 
      25                 :            : template< tk::ctr::RawRNGType id >
      26                 :>26324*10^7 : static inline double uniform( void*, void* )
      27                 :            : // *****************************************************************************
      28                 :            : //  Global-scope TestU01 uniform RNG wrapper
      29                 :            : //! \details This functions is used as an external uniform random number
      30                 :            : //!   generator (i.e., external to TestU01) that is called by the TestU01
      31                 :            : //!   library, hence the required signature and hence the global scope. It is
      32                 :            : //!   templated on a unique integer corresponding to the RNG type enum defined
      33                 :            : //!   by tk::ctr::RNGType. Templating on the id enables the compiler to generate
      34                 :            : //!   a different wrapper for a different RNG facilitating simultaneous calls to
      35                 :            : //!   any or all wrappers as they are unique functions.
      36                 :            : //! \return Random number generated as a double-precision floating point value
      37                 :            : // *****************************************************************************
      38                 :            : {
      39                 :>26324*10^7 :   double r = 0.0;
      40         [ +  - ]:>26324*10^7 :   const auto rng = g_rng.find( id );
      41         [ +  - ]:>26324*10^7 :   if (rng != end(g_rng))
      42         [ +  - ]:>26324*10^7 :     rng->second.uniform( CkMyPe(), 1, &r );
      43                 :            :   else
      44 [ -  - ][ -  - ]:          0 :     Throw( "RNG not found" );
                 [ -  - ]
      45                 :>26324*10^7 :   return r;
      46                 :            : }
      47                 :            : 
      48                 :            : template< tk::ctr::RawRNGType id >
      49                 :>12699*10^7 : static inline unsigned long uniform_bits( void*, void* )
      50                 :            : // *****************************************************************************
      51                 :            : //  Global-scope TestU01 uniform RNG bits wrapper
      52                 :            : //! \details This functions is used as an external uniform random number
      53                 :            : //!   generator (i.e., external to TestU01) that is called by the TestU01
      54                 :            : //!   library, hence the required signature and hence the global scope. It is
      55                 :            : //!   templated on a unique integer corresponding to the RNG type enum defined
      56                 :            : //!   by tk::ctr::RNGType. Templating on the id enables the compiler to generate
      57                 :            : //!   a different wrapper for a different RNG facilitating simultaneous calls to
      58                 :            : //!   any or all wrappers as they are unique functions.
      59                 :            : //! \return Random number generated as a unsigned long integer value
      60                 :            : // *****************************************************************************
      61                 :            : {
      62                 :>12699*10^7 :   double r = 0.0;
      63         [ +  - ]:>12699*10^7 :   const auto rng = g_rng.find( id );
      64         [ +  - ]:>12699*10^7 :   if (rng != end(g_rng))
      65         [ +  - ]:>12699*10^7 :     rng->second.uniform( CkMyPe(), 1, &r );
      66                 :            :   else
      67 [ -  - ][ -  - ]:          0 :     Throw( "RNG not found" );
                 [ -  - ]
      68                 :>12699*10^7 :   return static_cast<unsigned long>(r * unif01_NORM32);
      69                 :            : }
      70                 :            : 
      71                 :            : template< tk::ctr::RawRNGType id >
      72                 :        120 : static inline unif01_Gen* createTestU01Gen( const std::string& name )
      73                 :            : // *****************************************************************************
      74                 :            : //  Global-scope create TestU01 external generator
      75                 :            : //! \details This is the function that contains the TestU01 library call to
      76                 :            : //!   register a TestU01-external random number generator that later can be
      77                 :            : //!   subjected to the TestU01 batteries. It ties the unique global-scope
      78                 :            : //!   wrappers templated on the unique RNG id, thus TestU01 will see them as
      79                 :            : //!   different external generators.
      80                 :            : //! \param[in] name Random number generator name
      81                 :            : // *****************************************************************************
      82                 :            : {
      83                 :        120 :   return unif01_CreateExternGen01( const_cast<char*>(name.c_str()),
      84                 :        120 :                                    uniform< id >, uniform_bits< id > );
      85                 :            : }
      86                 :            : 
      87                 :            : } // rngtest::
      88                 :            : 
      89                 :            : #endif // TestU01Wrappers_h

Generated by: LCOV version 1.14