Skip to content

Instantly share code, notes, and snippets.

@liangwang0734
Created October 12, 2018 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangwang0734/a9533676245a80b949076b351c186dc4 to your computer and use it in GitHub Desktop.
Save liangwang0734/a9533676245a80b949076b351c186dc4 to your computer and use it in GitHub Desktop.
gkyl-5m-src-Eigen-time.patch
diff -r 0d6e9acd97dd App/PlasmaOnCartGrid.lua
--- a/App/PlasmaOnCartGrid.lua Fri Oct 12 11:29:08 2018 -0400
+++ b/App/PlasmaOnCartGrid.lua Fri Oct 12 13:21:32 2018 -0400
@@ -704,8 +704,10 @@
end
local tmSrc = 0.0
+ local tmSrcSol = 0.0
for _, s in pairs(sources) do
tmSrc = tmSrc + s:totalTime()
+ tmSrcSol = tmSrcSol + s:time_sol()
end
local tmTotal = tmSimEnd-tmSimStart
@@ -741,6 +743,9 @@
"Source updaters took %9.5f sec (%7.6f s/step) (%6.3f%%)\n",
tmSrc, tmSrc/step, 100*tmSrc/tmTotal))
log(string.format(
+ "Source Eigen sol took %9.5f sec (%7.6f s/step) (%6.3f%%)\n",
+ tmSrcSol, tmSrcSol/step, 100*tmSrcSol/tmTotal))
+ log(string.format(
"Stepper combine/copy took %9.5f sec (%7.6f s/step) (%6.3f%%)\n",
stepperTime, stepperTime/step, 100*stepperTime/tmTotal))
log(string.format(
diff -r 0d6e9acd97dd App/Sources/CollisionlessEmSource.lua
--- a/App/Sources/CollisionlessEmSource.lua Fri Oct 12 11:29:08 2018 -0400
+++ b/App/Sources/CollisionlessEmSource.lua Fri Oct 12 13:21:32 2018 -0400
@@ -96,4 +96,8 @@
return self.slvr.totalTime
end
+function CollisionlessEmSource:time_sol()
+ return tonumber(self.slvr._sd.time_sol / 1e9)
+end
+
return CollisionlessEmSource
diff -r 0d6e9acd97dd Updater/FiveMomentSrc.lua
--- a/Updater/FiveMomentSrc.lua Fri Oct 12 11:29:08 2018 -0400
+++ b/Updater/FiveMomentSrc.lua Fri Oct 12 13:21:32 2018 -0400
@@ -32,6 +32,7 @@
double gravity; /* Gravitational acceleration */
bool hasStatic, hasPressure; /* Flag to indicate if there is: static EB field, pressure */
int8_t linSolType; /* Flag to indicate linear solver type for implicit method */
+ long time_sol;
} FiveMomentSrcData_t;
void gkylFiveMomentSrcRk3(FiveMomentSrcData_t *sd, FluidData_t *fd, double dt, double **f, double *em);
@@ -107,6 +108,8 @@
elseif scheme == "time-centered" then
self._updateSrc = updateSrcTimeCentered
end
+
+ self._sd.time_sol = 0
end
-- advance method
@@ -159,4 +162,7 @@
return true, GKYL_MAX_DOUBLE
end
+function FiveMomentSrc:time_sol()
+ return self._sd.time_sol
+end
return FiveMomentSrc
diff -r 0d6e9acd97dd Updater/FiveMomentSrcImpl.cpp
--- a/Updater/FiveMomentSrcImpl.cpp Fri Oct 12 11:29:08 2018 -0400
+++ b/Updater/FiveMomentSrcImpl.cpp Fri Oct 12 13:21:32 2018 -0400
@@ -11,6 +11,7 @@
#include <string>
#include <cmath>
#include <Eigen/Eigen>
+#include <chrono>
// Makes indexing cleaner
static const unsigned X = 0;
@@ -199,6 +200,7 @@
rhs(eidx(EY)) = em[EY];
rhs(eidx(EZ)) = em[EZ];
+ auto start = std::chrono::high_resolution_clock::now();
// invert to find solution
if (sd->linSolType == COL_PIV_HOUSEHOLDER_QR)
sol = lhs.colPivHouseholderQr().solve(rhs);
@@ -206,6 +208,8 @@
sol = lhs.partialPivLu().solve(rhs);
else
{ /* can not happen */ }
+ auto finish = std::chrono::high_resolution_clock::now();
+ sd->time_sol += (double)std::chrono::duration_cast<std::chrono::nanoseconds>(finish-start).count();
//------------> update solution for fluids
double chargeDens = 0.0;
diff -r 0d6e9acd97dd Updater/FiveMomentSrcImpl.h
--- a/Updater/FiveMomentSrcImpl.h Fri Oct 12 11:29:08 2018 -0400
+++ b/Updater/FiveMomentSrcImpl.h Fri Oct 12 13:21:32 2018 -0400
@@ -23,6 +23,7 @@
double gravity; /* Gravitational acceleration */
bool hasStatic, hasPressure; /* Flag to indicate if there is: static EB field, pressure */
int8_t linSolType; /* Flag to indicate linear solver type for implicit method */
+ long time_sol;
} FiveMomentSrcData_t;
/* Method to update fluids and flield using explicit RK3 method */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment