|
|
|||
File indexing completed on 2026-01-10 10:05:47
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 celeritas/optical/gen/detail/UpdateSumExecutor.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Macros.hh" 0010 #include "corecel/Types.hh" 0011 0012 #include "../GeneratorData.hh" 0013 0014 namespace celeritas 0015 { 0016 namespace detail 0017 { 0018 //---------------------------------------------------------------------------// 0019 // LAUNCHER 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Subtract the number of tracks generated in the step from the cumulative sum. 0023 */ 0024 struct UpdateSumExecutor 0025 { 0026 //// DATA //// 0027 0028 NativeRef<GeneratorStateData> const offload; 0029 size_type num_gen{}; 0030 0031 //// FUNCTIONS //// 0032 0033 // Update the cumulative sum of the number of photons per distribution 0034 inline CELER_FUNCTION void operator()(TrackSlotId tid) const; 0035 CELER_FORCEINLINE_FUNCTION void operator()(ThreadId tid) const 0036 { 0037 return (*this)(TrackSlotId{tid.unchecked_get()}); 0038 } 0039 }; 0040 0041 //---------------------------------------------------------------------------// 0042 // INLINE DEFINITIONS 0043 //---------------------------------------------------------------------------// 0044 /*! 0045 * Update the cumulative sum of the number of photons per distribution. 0046 */ 0047 CELER_FUNCTION void UpdateSumExecutor::operator()(TrackSlotId tid) const 0048 { 0049 CELER_EXPECT(offload); 0050 CELER_EXPECT(num_gen > 0); 0051 CELER_EXPECT(tid < offload.offsets.size()); 0052 0053 auto& offset = offload.offsets[ItemId<size_type>(tid.get())]; 0054 if (offset < num_gen) 0055 { 0056 offset = 0; 0057 } 0058 else 0059 { 0060 offset -= num_gen; 0061 } 0062 } 0063 0064 //---------------------------------------------------------------------------// 0065 } // namespace detail 0066 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|