Commit a7fa757a authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART

- added setting to enable / disable multi-threading for ray tracing
parent db2cf808
......@@ -68,8 +68,9 @@ namespace ITAPropagationPathSim
};
struct ITA_PROPAGATION_PATH_SIM_API Settings {
SolverMethod solverMethod = SolverMethod::EULER;
double dIntegrationTimeStep = 0.1;
SolverMethod solverMethod = SolverMethod::RUNGE_KUTTA;
double dIntegrationTimeStep = 0.1; //!< Base step size for time integration
bool bMultiThreading = true; //!< If this is activated, tracing multiple rays in a single call is done using multi-threading
AdaptiveIntegrationSettings adaptiveIntegration;
};
}
......
......@@ -165,13 +165,27 @@ void CEngine::TraceRays(const ITAGeo::CStratifiedAtmosphere& atmosphere, const s
if (!simulationWatcher)
ITA_EXCEPT_INVALID_PARAMETER("Simulation-Engine: Interface to external watcher is not set. Cannot run simulation.");
#pragma omp parallel for schedule(static)
for (int idx = 0; idx < rays.size(); idx++)
if (settings.bMultiThreading)
{
if (rays[idx] == nullptr)
continue;
auto worker = CWorker(rays[idx], settings, *simulationWatcher);
worker.TraceRay(atmosphere);
#pragma omp parallel for schedule(static)
for (int idx = 0; idx < rays.size(); idx++)
{
if (rays[idx] == nullptr)
continue;
auto worker = CWorker(rays[idx], settings, *simulationWatcher);
worker.TraceRay(atmosphere);
}
}
else
{
for (int idx = 0; idx < rays.size(); idx++)
{
if (rays[idx] == nullptr)
continue;
auto worker = CWorker(rays[idx], settings, *simulationWatcher);
worker.TraceRay(atmosphere);
}
}
}
......@@ -97,7 +97,7 @@ void TestInhomogeneousAtmosphere(const double& sourceAltitude, const VistaVector
runTest(inhomogeneousAtmosphere, sourceAltitude, rayDirection, fileSuffix);
}
void TestTraceMultipleRays()
void TestTraceMultipleRays(bool bUseMultiThreading)
{
auto humidProfile = std::make_shared<HumidityProfiles::CConstant>(50);
auto tempProfile = std::make_shared<TemperatureProfiles::CISA>();
......@@ -105,6 +105,7 @@ void TestTraceMultipleRays()
auto atmosphere = CStratifiedAtmosphere(tempProfile, windProfile, humidProfile);
auto engine = Simulation::CEngine();
engine.settings.bMultiThreading = bUseMultiThreading;
VistaVector3D sourcePosition = VistaVector3D(0, 0, 1000);
auto baseRayGrid = CEquiangularRayDistribution(sourcePosition, 8, 2);
......@@ -117,14 +118,21 @@ void TestTraceMultipleRays()
engine.Run(atmosphere, rayGrid.UniqueRays());
sw.stop();
}
cout << "Benchmark with OpenMP:" << endl;
if (bUseMultiThreading)
cout << "Benchmark with OpenMP:" << endl;
else
cout << "Benchmark without OpenMP:" << endl;
cout << sw << endl << endl;
}
int main(int iNumInArgs, char* pcInArgs[])
{
TestTraceMultipleRays();
//Sequential
TestTraceMultipleRays(false);
//Multithreading
TestTraceMultipleRays(true);
double sourceAltitude = 1000;
auto rayDirection = VistaVector3D(1, 0, -1).GetNormalized();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment