Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-26 09:34:37

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/random/data/detail/RanluxppRngStateInit.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/random/data/RanluxppRngData.hh"
0013 #include "corecel/random/engine/RanluxppRngEngine.hh"
0014 
0015 namespace celeritas
0016 {
0017 namespace detail
0018 {
0019 
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Initialize the given track slot.
0023  */
0024 struct RanluxppRngSeedExecutor
0025 {
0026     NativeCRef<RanluxppRngParamsData> const params;
0027     NativeRef<RanluxppRngStateData> const state;
0028 
0029     //! Initialize the given track slot.
0030     inline CELER_FUNCTION void operator()(TrackSlotId tid) const
0031     {
0032         CELER_EXPECT(tid < state.size());
0033         RanluxppRngEngine rng(params, state, tid);
0034 
0035         // Hard-code offset to 0
0036         RanluxppUInt offset = 0;
0037         rng = {params.seed, tid.unchecked_get(), offset};
0038     }
0039 
0040     //! Initialize from the given thread.
0041     CELER_FORCEINLINE_FUNCTION void operator()(ThreadId tid) const
0042     {
0043         return (*this)(TrackSlotId{tid.unchecked_get()});
0044     }
0045 };
0046 
0047 //---------------------------------------------------------------------------//
0048 // Initialize the RNG state on host/device
0049 void ranlux_state_init(DeviceCRef<RanluxppRngParamsData> const& params,
0050                        DeviceRef<RanluxppRngStateData> const& state,
0051                        StreamId stream);
0052 
0053 void ranlux_state_init(HostCRef<RanluxppRngParamsData> const& params,
0054                        HostRef<RanluxppRngStateData> const& state,
0055                        StreamId);
0056 
0057 #if !CELER_USE_DEVICE
0058 //---------------------------------------------------------------------------//
0059 /*!
0060  * Initialize the RNG states on device.
0061  */
0062 inline void ranlux_state_init(DeviceCRef<RanluxppRngParamsData> const&,
0063                               DeviceRef<RanluxppRngStateData> const&,
0064                               StreamId)
0065 {
0066     CELER_ASSERT_UNREACHABLE();
0067 }
0068 #endif
0069 
0070 //---------------------------------------------------------------------------//
0071 }  // namespace detail
0072 }  // namespace celeritas