forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into action-times
- Loading branch information
Showing
19 changed files
with
316 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/random/RngReseed.cc | ||
//---------------------------------------------------------------------------// | ||
#include "RngReseed.hh" | ||
|
||
#include "corecel/cont/Range.hh" | ||
#include "corecel/sys/ThreadId.hh" | ||
|
||
#include "RngEngine.hh" | ||
|
||
namespace celeritas | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Reinitialize the RNG states on host at the start of an event. | ||
* | ||
* Each thread's state is initialized using same seed and skipped ahead a | ||
* different number of subsequences so the sequences on different threads will | ||
* not have statistically correlated values. | ||
*/ | ||
void reseed_rng(HostCRef<RngParamsData> const& params, | ||
HostRef<RngStateData> const& state, | ||
size_type event_id) | ||
{ | ||
for (auto tid : range(TrackSlotId{state.size()})) | ||
{ | ||
RngEngine::Initializer_t init; | ||
init.seed = params.seed; | ||
init.subsequence = event_id * state.size() + tid.get(); | ||
RngEngine engine(params, state, tid); | ||
engine = init; | ||
} | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//---------------------------------*-CUDA-*----------------------------------// | ||
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/random/RngReseed.cu | ||
//---------------------------------------------------------------------------// | ||
#include "RngReseed.hh" | ||
|
||
#include "corecel/device_runtime_api.h" | ||
#include "corecel/Assert.hh" | ||
#include "corecel/sys/Device.hh" | ||
#include "corecel/sys/KernelParamCalculator.device.hh" | ||
|
||
#include "RngEngine.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace | ||
{ | ||
//---------------------------------------------------------------------------// | ||
// KERNELS | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Reinitialize the RNG states on device at the start of an event. | ||
*/ | ||
__global__ void reseed_rng_kernel(DeviceCRef<RngParamsData> const params, | ||
DeviceRef<RngStateData> const state, | ||
size_type event_id) | ||
{ | ||
auto tid = TrackSlotId{ | ||
celeritas::KernelParamCalculator::thread_id().unchecked_get()}; | ||
if (tid.get() < state.size()) | ||
{ | ||
TrackSlotId tsid{tid.unchecked_get()}; | ||
RngEngine::Initializer_t init; | ||
init.seed = params.seed; | ||
init.subsequence = event_id * state.size() + tsid.get(); | ||
RngEngine rng(params, state, tsid); | ||
rng = init; | ||
} | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace | ||
|
||
//---------------------------------------------------------------------------// | ||
// KERNEL INTERFACE | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Reinitialize the RNG states on device at the start of an event. | ||
* | ||
* Each thread's state is initialized using same seed and skipped ahead a | ||
* different number of subsequences so the sequences on different threads will | ||
* not have statistically correlated values. | ||
*/ | ||
void reseed_rng(DeviceCRef<RngParamsData> const& params, | ||
DeviceRef<RngStateData> const& state, | ||
size_type event_id) | ||
{ | ||
CELER_EXPECT(state); | ||
CELER_EXPECT(params); | ||
CELER_LAUNCH_KERNEL(reseed_rng, state.size(), 0, params, state, event_id); | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/random/RngReseed.hh | ||
//---------------------------------------------------------------------------// | ||
#pragma once | ||
|
||
#include "corecel/Assert.hh" | ||
#include "corecel/Macros.hh" | ||
#include "corecel/Types.hh" | ||
#include "corecel/data/Collection.hh" | ||
|
||
#include "RngData.hh" | ||
|
||
namespace celeritas | ||
{ | ||
//---------------------------------------------------------------------------// | ||
// Reinitialize the RNG states on host/device at the start of an event | ||
void reseed_rng(DeviceCRef<RngParamsData> const&, | ||
DeviceRef<RngStateData> const&, | ||
size_type); | ||
|
||
void reseed_rng(HostCRef<RngParamsData> const&, | ||
HostRef<RngStateData> const&, | ||
size_type); | ||
|
||
#if !CELER_USE_DEVICE | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Reinitialize the RNG states on device at the start of an event. | ||
*/ | ||
inline void reseed_rng(DeviceCRef<RngParamsData> const&, | ||
DeviceRef<RngStateData> const&, | ||
size_type) | ||
{ | ||
CELER_ASSERT_UNREACHABLE(); | ||
} | ||
#endif | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.