|
|
|||
File indexing completed on 2026-11-27 10:26:31
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/DirectGeneratorExecutor.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Macros.hh" 0010 #include "corecel/Types.hh" 0011 #include "celeritas/optical/CoreTrackView.hh" 0012 #include "celeritas/track/CoreStateCounters.hh" 0013 #include "celeritas/track/Utils.hh" 0014 0015 #include "../DirectGeneratorData.hh" 0016 0017 namespace celeritas 0018 { 0019 namespace optical 0020 { 0021 namespace detail 0022 { 0023 //---------------------------------------------------------------------------// 0024 /*! 0025 * Directly initialize photons. 0026 */ 0027 struct DirectGeneratorExecutor 0028 { 0029 CRefPtr<CoreParamsData, MemSpace::native> params; 0030 RefPtr<CoreStateData, MemSpace::native> state; 0031 NativeRef<DirectGeneratorStateData> const data; 0032 0033 // Initialize optical photons 0034 inline CELER_FUNCTION void operator()(ThreadId tid) const; 0035 }; 0036 0037 //---------------------------------------------------------------------------// 0038 // INLINE DEFINITIONS 0039 //---------------------------------------------------------------------------// 0040 /*! 0041 * Initialize optical photons. 0042 */ 0043 CELER_FUNCTION void DirectGeneratorExecutor::operator()(ThreadId tid) const 0044 { 0045 CELER_EXPECT(params); 0046 CELER_EXPECT(state); 0047 0048 auto* counters = state->init.counters.data().get(); 0049 0050 // Original code set the number of threads to the minimum between of number 0051 // of vacancies and the number of pending in the auxiliary state. To avoid 0052 // accessing the state counters to compute this min, we skip the extra 0053 // threads if counters->num_vacancies < aux_state.counters.num_pending 0054 if (!(tid < counters->num_vacancies)) 0055 { 0056 return; 0057 } 0058 0059 // Create view to new track to be initialized 0060 CoreTrackView vacancy(*params, *state, [&] { 0061 TrackSlotId idx{index_before(counters->num_vacancies, tid)}; 0062 return state->init.vacancies[idx]; 0063 }()); 0064 0065 // Get initializer from the back 0066 TrackInitializer const& init = data.initializers[ItemId<TrackInitializer>( 0067 index_before(counters->num_pending, tid))]; 0068 0069 // Initialize track 0070 vacancy = init; 0071 } 0072 0073 //---------------------------------------------------------------------------// 0074 } // namespace detail 0075 } // namespace optical 0076 } // 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 |
|