.. _program_listing_file_include_embers_rand_rand.h: Program Listing for File rand.h =============================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/embers/rand/rand.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* Copyright © 2020 Advanced Micro Devices, Inc. All rights reserved */ #ifndef _EMBERS_RAND_H #define _EMBERS_RAND_H #include #include namespace embers { namespace rand { template inline __device__ __host__ T rand(uint32_t seed) { static constexpr uint64_t ANSIC_LCG_MULTIPLIER = 1103515245; static constexpr uint64_t ANSIC_LCG_ADDEND = 12345; const uint64_t rval_lo = (static_cast(seed) * ANSIC_LCG_MULTIPLIER + ANSIC_LCG_ADDEND) >> 9; const uint64_t rval_hi = (rval_lo * ANSIC_LCG_MULTIPLIER + ANSIC_LCG_ADDEND) << 20; return static_cast(rval_lo ^ rval_hi); } } // namespace rand } // namespace embers #endif