[WIP] Add Branson Monte Carlo Kernel - #683
Conversation
|
Is there a better name for this kernel? |
I am open to suggestions, but it can be renamed easily. |
|
I'm fine with the name. @MrBurmark do you have a specific concern about the name? |
|
The name is just very generic. Is the kernel any specific part of the Monty Carlo algorithm? |
That's a good point. A brief scan of the code at the link @michaelmckinsey1 provided above to the Branson code, perhaps something like MC_EVENT_PHOTON_TRANSPORT, if that's not too long. |
|
@michaelmckinsey1 please add a reference implementation to the kernel header file. |
…l-photon-transport
There was a problem hiding this comment.
probably don't want this and would be good to double check on the other extra files
There was a problem hiding this comment.
Yes, there are a bunch of unwanted files committed in this. Please refrain from using git add *.
| transport3dmc_lam_setup(vid, iend); | ||
| // Loop counter increment uses macro to quiet C++20 compiler warning | ||
| for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) { | ||
| transport3dmc_lam_reset(); |
There was a problem hiding this comment.
Only the loop body needs to be in a lambda.
There was a problem hiding this comment.
Unless the reset is also a loop body.
| case Base_Seq : { | ||
|
|
||
| startTimer(); | ||
| TRANSPORT3DMC_DATA_SETUP(vid, iend); |
There was a problem hiding this comment.
Setup should happen once above the variant switch statement.
| TRANSPORT3DMC_DATA_SETUP(vid, iend); | ||
| // Loop counter increment uses macro to quiet C++20 compiler warning | ||
| for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) { | ||
| TRANSPORT3DMC_RESET |
There was a problem hiding this comment.
If reset involves a loop from begin to end, you probably want to express that loop outside of the reset macro.
There was a problem hiding this comment.
No loop, just a deep copy of the reference set to another object actually conducting transport.
| setItsPerRep( getActualProblemSize() ); | ||
| setKernelsPerRep(1); | ||
|
|
||
| setBytesAllocatedPerRep( 0 ); // in, out | ||
| setBytesReadPerRep( 0 ); // in | ||
| setBytesWrittenPerRep( 0 ); // out | ||
| setBytesModifyWrittenPerRep( 0 ); | ||
| setBytesAtomicModifyWrittenPerRep( 0 ); | ||
| setFLOPsPerRep( 0 ); |
There was a problem hiding this comment.
Might want to add a TODO comment as a reminder.
|
|
||
| void TRANSPORT3DMC::initMaterials(std::vector<TRANSPORT3DMC::Material> &mats) { | ||
| size_t matCt = 12; | ||
| mats.resize(matCt); |
There was a problem hiding this comment.
You'll probably want to use something like allocDataForInit to get memory here and allow you to manually set it up. Note that all setup for the data must be completed before the object returned by allocDataForInit goes out of scope, see examples by searching for ForInit.
| { | ||
| } | ||
|
|
||
| int TRANSPORT3DMC::Cell::GLBL = 0; |
There was a problem hiding this comment.
Why are you using static class variables?
There was a problem hiding this comment.
Since the mesh is an array, the static GLBL helps to identify/assign cells their ID/index into the mesh vector. Can probably be removed once all vectors have been migrated to pointers.
| #define dT 0.001 | ||
| #define N_ISOTOPE 68 | ||
| //#define GROUPS 10 | ||
| #define cutoff 1e-5 |
There was a problem hiding this comment.
Though you may be able to make these static constexpr class variables instead.
| public: | ||
| static int GLBL; | ||
| int ID; | ||
| std::array<double, 6> planes; //-x, +x, -y, +y, -z, +z |
There was a problem hiding this comment.
You might want to use camp::array, its the same as std::array but works on gpus.
| SOURCE, | ||
| }; | ||
|
|
||
| struct XS { |
There was a problem hiding this comment.
Rename to CrossSection for clarity?
| XS operator*(const double c) const; | ||
| XS operator+(const XS &sigma) const; |
There was a problem hiding this comment.
Define inline for performance?
|
|
||
| struct Material { | ||
| int isotopeCt; | ||
| std::vector<double> conc; |
There was a problem hiding this comment.
Prefer allocData and deallocData and related helper functions to get memory.
| transport3dMC_particles(10000), | ||
| transport3dMC_cube_dim(3), | ||
| transport3dMC_groups(10), |
There was a problem hiding this comment.
Nice, we'll have to have to think about what are reasonable defaults later.
| /install_*/ | ||
| /install-*/ | ||
| /Debug/ | ||
| *.cmake |
There was a problem hiding this comment.
This seems a bit broad, don't we use cmake?
There was a problem hiding this comment.
removed, checked out the gitignore from develop
| setDefaultProblemSize(1); | ||
| setDefaultReps(1000); |
There was a problem hiding this comment.
This is fine for now, long term I'm going to guess this is going to move toward values like this.
| setDefaultProblemSize(1); | |
| setDefaultReps(1000); | |
| setDefaultProblemSize(1000000); | |
| setDefaultReps(10); |
| setSize(params.getTargetSize(getDefaultProblemSize()), | ||
| params.getReps(getDefaultReps())); | ||
|
|
||
| setChecksumConsistency(ChecksumConsistency::ConsistentPerVariantTuning); |
There was a problem hiding this comment.
Hopefully this stays consistent as we'll have consistent pseudo random numbers.
| TRANSPORT3DMC::Material::Material() { | ||
| isotopeCt = 1; | ||
| conc = std::vector<double>(); | ||
| nucIDs = std::vector<int>(); | ||
| } |
There was a problem hiding this comment.
This is fine for now, but c++ has a syntax for initializing class members https://en.cppreference.com/cpp/language/constructor.
There was a problem hiding this comment.
Ended up just deleting it and letting the compiler define a default constructor.
|
I was reading through earlier comments, I disagree with the name MC_EVENT_PHOTON_TRANSPORT; the kernel emulates history-based transport of neutrons (or at least that's how I designed it). |
If the difference is history vs event, why not |
Well it's not really photons, at least I don't think. Also I was more trying to keep with the 3D kernel's naming scheme (MASS3D, CONVECTION3D, VOL3D, DIFFUSION3D, etc). If this convention isn't desired for this kernel then we can stay with the |
I don't think there is much reason to limit yourself to that 3D naming convention as this is a different type of kernel. |
…l-photon-transport Update to develop
Summary
An intern (@RanivG) will be implementing https://github.com/lanl/branson/blob/3f538e31a51b144b6621d4665f465d8d44ee85b8/src/event_based_transport.h#L323 as a kernel in RAJAPerf.
Apps_MC_HISTORY_PARTICLE_TRANSPORTkernelMC_HISTORY_PARTICLE_TRANSPORT