I have recently noticed that when I run my program, only one processor is used, which takes a really long time to execute. I narrow things down to this while loop that takes the majority of the runtime:
double xc = 0., yc = 0., zc = 0., tc = 0., ec = 0., extra = 0.;
int nc = 0;
while (track.GetCluster(xc, yc, zc, tc, nc, ec, extra)) {
for (int k = 0; k < nc; ++k) {
double xe = 0., ye = 0., ze = 0., te = 0., ee = 0.;
double dx = 0., dy = 0., dz = 0.;
track.GetElectron(k, xe, ye, ze, te, ee, dx, dy, dz);
aval.AvalancheElectron(xe, ye, ze, te, ee, dx, dy, dz);
const int np = aval.GetNumberOfElectronEndpoints();
double xe1, ye1, ze1, te1, e1;
double xe2, ye2, ze2, te2, e2;
double xi1, yi1, zi1, ti1;
double xi2, yi2, zi2, ti2;
int status;
for (int j = np; j--;) {
aval.GetElectronEndpoint(j, xe1, ye1, ze1, te1, e1,
xe2, ye2, ze2, te2, e2, status);
drift.DriftIon(xe1, ye1, ze1, te1);
Given the nature of the first for loop, this seems like a good opportunity to run things in parallel. My first thought was to make copies of track and then break up the for loop. However, after looking at the source and header files of TrackHeed, it seems like making copies of track is a bad idea since the operator= was explicitly made private to prevent track from being copied.
I am looking for any suggestions on how to parallelize this part. Thank you!