Skip to content

Commit 9377092

Browse files
authored
Recompute macroscopic cross-section in example19 (#235)
Instead of storing to memory, just redo the computation in case a photoelectric interaction was selected. No performance difference, but less memory usage.
1 parent e6dc268 commit 9377092

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

examples/Example19/example.cuh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ struct Track {
5757
// Struct for communication between kernels
5858
struct SOAData {
5959
char *nextInteraction = nullptr;
60-
double *gamma_PEmxSec = nullptr;
6160
};
6261

6362
#ifdef __CUDA_ARCH__

examples/Example19/gammas.cu

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ __global__ void TransportGammas(Track *gammas, const adept::MParray *active, Sec
117117
currentTrack.numIALeft[winnerProcessIndex] = -1.0;
118118

119119
soaData.nextInteraction[i] = winnerProcessIndex;
120-
soaData.gamma_PEmxSec[i] = gammaTrack.GetPEmxSec();
121120
survive(false);
122121
}
123122
}
@@ -217,8 +216,12 @@ __device__ void GammaInteraction(int const globalSlot, SOAData const &soaData, i
217216
// Invoke photoelectric process.
218217
const double theLowEnergyThreshold = 1 * copcore::units::eV;
219218

219+
// (Re)compute total macroscopic cross section
220+
const int theMatIndx = g4HepEmData.fTheMatCutData->fMatCutData[theMCIndex].fHepEmMatIndex;
221+
double mxsec = G4HepEmGammaManager::GetMacXSecPE(&g4HepEmData, theMatIndx, energy);
222+
220223
const double bindingEnergy = G4HepEmGammaInteractionPhotoelectric::SelectElementBindingEnergy(
221-
&g4HepEmData, theMCIndex, soaData.gamma_PEmxSec[soaSlot], energy, &rnge);
224+
&g4HepEmData, theMCIndex, mxsec, energy, &rnge);
222225

223226
double edep = bindingEnergy;
224227
const double photoElecE = energy - edep;

examples/Example19/main.cu

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ void runGPU(int numParticles, double energy, int batch, const int *MCIndex_host,
218218
COPCORE_CUDA_CHECK(
219219
cudaMalloc(&particles[i].soaData.nextInteraction, sizeof(SOAData::nextInteraction[0]) * Capacity));
220220
}
221-
COPCORE_CUDA_CHECK(
222-
cudaMalloc(&particles[ParticleType::Gamma].soaData.gamma_PEmxSec, sizeof(SOAData::gamma_PEmxSec[0]) * Capacity));
223221
COPCORE_CUDA_CHECK(cudaDeviceSynchronize());
224222

225223
ParticleType &electrons = particles[ParticleType::Electron];
@@ -506,6 +504,5 @@ void runGPU(int numParticles, double energy, int batch, const int *MCIndex_host,
506504
COPCORE_CUDA_CHECK(cudaEventDestroy(particles[i].event));
507505

508506
COPCORE_CUDA_CHECK(cudaFree(particles[i].soaData.nextInteraction));
509-
if (particles[i].soaData.gamma_PEmxSec) COPCORE_CUDA_CHECK(cudaFree(particles[i].soaData.gamma_PEmxSec));
510507
}
511508
}

0 commit comments

Comments
 (0)