Compare commits

..

8 Commits

Author SHA1 Message Date
Max Lübke
42b6ed40fe chore: Move content from source to header 2024-08-30 10:13:33 +00:00
Danny Puhan
fac2c07a3e Fix submodules 2024-08-09 17:42:48 +02:00
DannyPuhan
dc9962a6d6 Undo https url in .gitmodules 2024-07-09 11:33:39 +02:00
DannyPuhan
5b7e062e68 Fix URL in .gitmodules. 2024-07-09 11:27:05 +02:00
DannyPuhan
a7c192c808 Fix URL in .gitmodules. 2024-07-09 11:15:34 +02:00
Max Lübke
462c3d4716 Update benchmark runtimes according to timings from PERFACCT 2024-07-04 12:01:59 +02:00
Max Lübke
20c2917606 Merge branch 'feat-set-num-threads-via-env-variable' into 'master'
[feat] Set number of threads via env variable `OMP_NUM_THREADS`.

See merge request naaice/naaice_tug_input!1
2024-06-06 11:55:12 +02:00
DannyPuhan
4692a246d5 [feat] Set number of threads via env variable OMP_NUM_THREADS. 2024-06-06 09:45:42 +02:00
7 changed files with 177 additions and 315 deletions

Binary file not shown.

View File

@ -43,13 +43,13 @@ At a glance:
\centering
\begin{tabular}{|c|c|}
\hline
Grid & 200x200 \\ \hline
Size & 1x1~m$^2$ \\ \hline
Timestep & 1000~s \\ \hline
Iterations & 50 \\ \hline
$\alpha_x, \alpha_y$ & heter., aniso. \\\hline
Species \# & 7 \\ \hline
Init & homog. \\ \hline
Grid & 200x200 \\ \hline
Size & 1x1~m$^2$ \\ \hline
Timestep & 1000~s \\ \hline
Iterations & 50 \\ \hline
$\alpha_x, \alpha_y$ & heter., aniso. \\\hline
Species \# & 7 \\ \hline
Init & homog. \\ \hline
\end{tabular}
\caption{Summary of parameters for the barite\_200 benchmark}
\label{tab:b200}
@ -68,9 +68,9 @@ value of 0.1 molal \chem{BaCl_2}. All other boundaries are closed.
\begin{table*}[!h]
\centering
\begin{tabular}{|r|r|r|r|r|r|r|r|}\hline
& H & O & Charge & Ba & Cl & S\_6\_ & Sr \\\hline
\textbf{IC} & 110.0124 & 55.5086 & -1.2163e-09 & 4.4553e-07 & 2.0e-12 & 6.1516e-5 & 6.1472e-5 \\\hline
\textbf{BC} & 111.0124 & 55.5062 & -3.3370e-08 & 0.1 & 0.2 & 0 & 0 \\\hline
& H & O & Charge & Ba & Cl & S\_6\_ & Sr \\\hline
\textbf{IC} & 110.0124 & 55.5086 & -1.2163e-09 & 4.4553e-07 & 2.0e-12 & 6.1516e-5 & 6.1472e-5 \\\hline
\textbf{BC} & 111.0124 & 55.5062 & -3.3370e-08 & 0.1 & 0.2 & 0 & 0 \\\hline
\end{tabular}
\caption{Initial and boundary values of all transported variables in
the \texttt{barite\_200} benchmark.}
@ -87,8 +87,8 @@ for $\alpha_x$ and $\alpha_y$ respectively:
\begin{equation*}
\begin{cases}
\displaystyle \alpha_x & \displaystyle = 10^{-7} + 10^{-6} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}\\
\alpha_y & \displaystyle = 10^{-7} + 10^{-7} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}
\displaystyle \alpha_x & \displaystyle = 10^{-7} + 10^{-6} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}} \\
\alpha_y & \displaystyle = 10^{-7} + 10^{-7} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}
\end{cases}
\end{equation*}
@ -111,7 +111,7 @@ benchmark.
\end{figure}
This benchmarks runs in $\sim$11~s on 8 CPUs on my desktop.
This benchmarks runs in $\sim$ 1.8~s on 18 CPUs on a System @ PERFACCT.
\clearpage
@ -128,13 +128,13 @@ At a glance:
\centering
\begin{tabular}{|c|c|}
\hline
Grid & 1000x1000 \\ \hline
Size & 10x10~m \\ \hline
Timestep & 100~s \\ \hline
Iterations & 50 \\ \hline
Grid & 1000x1000 \\ \hline
Size & 10x10~m \\ \hline
Timestep & 100~s \\ \hline
Iterations & 50 \\ \hline
$\alpha$ & homog. 1E-6 \\\hline
Species \# & 7 \\ \hline
Init & heter. \\ \hline
Species \# & 7 \\ \hline
Init & heter. \\ \hline
\end{tabular}
\caption{Summary of parameters for the \texttt{barite\_large} benchmark}
\label{tab:blarge}
@ -181,7 +181,7 @@ record. The non-rounded values are read from file
\texttt{barite\_200} benchmark\label{fig:blarge}}
\end{figure}
This benchmark runs in $\sim$30~s on my desktop using 8 CPUs.
This benchmark runs in $\sim$6.4~s on my desktop using 18 CPUs.
\clearpage
@ -197,7 +197,7 @@ glance:
\centering
\begin{tabular}{|c|c|}
\hline
Grid & 200x100 \\ \hline
Grid & 200x100 \\ \hline
Size & 0.02x0.01~m \\ \hline
Timestep & 3600~s (1~h) \\ \hline
Iterations & 20 \\ \hline
@ -216,28 +216,28 @@ boundaries are set to constant \textbf{BC} values. \textbf{Initial
\begin{table*}[!h]
\centering
\begin{tabular}{|l|r|r|}\hline
& \textbf{IC} & \textbf{BC} \\ \hline
H & 1.11e+02 & 120.0 \\ \hline
O & 5.55e+01 & 55.1 \\ \hline
Charge & -2.0e-13 & 8.0e-17 \\ \hline
C & 2.0e-16 & 2.0e-15 \\ \hline
CH4 & 2.0e-03 & 0.2 \\ \hline
Ca & 2.0e-01 & 0.03 \\ \hline
Cl & 3.0e-01 & 0.5 \\ \hline
Fe2 & 1.4e-04 & 0.0002 \\ \hline
Fe3 & 1.3e-09 & 2.0e-08 \\ \hline
H0 & 6.0e-12 & 2.0e-11 \\ \hline
K & 2.0e-03 & 1.0e-05 \\ \hline
Mg & 1.0e-02 & 0.2 \\ \hline
Na & 2.0e-01 & 0.3 \\ \hline
HS2 & 5.9e-10 & 0 \\ \hline
S2 & 8.3e-15 & 8.3e-12 \\ \hline
S4 & 2.1e-14 & 5.1e-14 \\ \hline
S6 & 1.6e-02 & 0.026 \\ \hline
Sr & 4.5e-04 & 0.045 \\ \hline
U4 & 2.5e-09 & 2.5e-08 \\ \hline
U5 & 1.6e-10 & 1.6e-10 \\ \hline
U6 & 2.3e-07 & 1.0e-05 \\ \hline
& \textbf{IC} & \textbf{BC} \\ \hline
H & 1.11e+02 & 120.0 \\ \hline
O & 5.55e+01 & 55.1 \\ \hline
Charge & -2.0e-13 & 8.0e-17 \\ \hline
C & 2.0e-16 & 2.0e-15 \\ \hline
CH4 & 2.0e-03 & 0.2 \\ \hline
Ca & 2.0e-01 & 0.03 \\ \hline
Cl & 3.0e-01 & 0.5 \\ \hline
Fe2 & 1.4e-04 & 0.0002 \\ \hline
Fe3 & 1.3e-09 & 2.0e-08 \\ \hline
H0 & 6.0e-12 & 2.0e-11 \\ \hline
K & 2.0e-03 & 1.0e-05 \\ \hline
Mg & 1.0e-02 & 0.2 \\ \hline
Na & 2.0e-01 & 0.3 \\ \hline
HS2 & 5.9e-10 & 0 \\ \hline
S2 & 8.3e-15 & 8.3e-12 \\ \hline
S4 & 2.1e-14 & 5.1e-14 \\ \hline
S6 & 1.6e-02 & 0.026 \\ \hline
Sr & 4.5e-04 & 0.045 \\ \hline
U4 & 2.5e-09 & 2.5e-08 \\ \hline
U5 & 1.6e-10 & 1.6e-10 \\ \hline
U6 & 2.3e-07 & 1.0e-05 \\ \hline
\end{tabular}
\caption{\texttt{surfex} benchmark, homogeneous initial conditions
\textbf{IC} and boundary values \textbf{BC}}
@ -260,7 +260,7 @@ boundaries are set to constant \textbf{BC} values. \textbf{Initial
benchmark\label{fig:bsurf}}
\end{figure}
This benchmark runs in $\sim$7~s on my desktop using 8 CPUs.
This benchmark runs in $\sim$1.1~s on my desktop using 18 CPUs.
\clearpage
@ -314,7 +314,7 @@ equivalent):
\begin{equation}
\label{eq:GMAQ}
\text{Geometric Mean of Absolute Quotients} = \left(\prod
\left|\frac{\hat{y}_{i}}{y_i}\right|\right)^{\frac {1}{N}}
\left|\frac{\hat{y}_{i}}{y_i}\right|\right)^{\frac {1}{N}}
\end{equation}
The geometric mean of the quotients would be 1 if the two variables
@ -325,7 +325,7 @@ of the terms:
\begin{equation}
\label{eq:5}
\exp \left[{\frac {1}{N}}\sum\log a_{i}\right]= \left(\prod
a_{i}\right)^{\frac {1}{N}}
a_{i}\right)^{\frac {1}{N}}
\end{equation}
So the \chem{MAE_{log}} is the logarithm of the actual geometric mean
@ -337,9 +337,9 @@ error $\alpha_i$ as:
\label{eq:relalpha}
\alpha_i =
\begin{cases}
\displaystyle \frac{ y_i-\hat{y_i}}{y_i} & \text{if~} \hspace{0.1cm} y_i,\hat{y}_i \neq 0 \\
1 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i \neq 0 \\
0 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i = 0 \\
\displaystyle \frac{ y_i-\hat{y_i}}{y_i} & \text{if~} \hspace{0.1cm} y_i,\hat{y}_i \neq 0 \\
1 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i \neq 0 \\
0 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i = 0 \\
\end{cases}
\end{equation}
@ -351,12 +351,12 @@ Absolute Percentage Error (\textbf{MAPE}) and Relative RMSE
\begin{equation}
\label{eq:MAPE}
\text{MAPE} = \frac{100\%}{N}\sum \left| \alpha_i \right|
\text{MAPE} = \frac{100\%}{N}\sum \left| \alpha_i \right|
\end{equation}
\begin{equation}
\label{eq:RRMSE}
\text{RRMSE} = \sqrt{\frac{1}{N}\sum \left( \alpha_i\right)^2}
\text{RRMSE} = \sqrt{\frac{1}{N}\sum \left( \alpha_i\right)^2}
\end{equation}
These relative measures account for discrepancies across all

View File

@ -1,8 +1,8 @@
## Time-stamp: "Last modified 2024-04-11 15:28:06 delucia"
## Time-stamp: "Last modified 2024-04-10 22:38:14 delucia"
## Compile the fortran code. On Linux, if a fortran compiler is
## installed, it should work out of the box
here <- getwd()
setwd("/home/work/simR/Rphree/SpecSim/")
system("R CMD SHLIB SS_Sim.f SS_Vario.f -o SSlib.so")
dyn.load("SSlib.so")
@ -10,60 +10,11 @@ dyn.load("SSlib.so")
## Load the functions
source("SS_Fun_sim.R")
source("SS_Fun_vario.R")
setwd("/home/work/simR/Rphree/NAAICE_tug_input/build")
setwd(here)
library(lattice)
library(PoetUtils)
PlotField2 <- function (data, grid, nx, ny, contour = TRUE, nlevels = 12, breaks,
palette = "heat.colors", rev.palette = TRUE, scale = TRUE,
plot.axes = TRUE, ...)
{
if (!missing(grid)) {
xc <- unique(sort(grid$cell$XCOORD))
yc <- unique(sort(grid$cell$YCOORD))
nx <- length(xc)
ny <- length(yc)
if (!length(data) == nx * ny)
stop("Wrong nx, ny or grid")
}
else {
xc <- seq(1, nx)
yc <- seq(1, ny)
}
z <- matrix(round(data, 6), ncol = nx, nrow = ny, byrow = TRUE)
pp <- t(z[rev(seq(1, nrow(z))), ])
if (missing(breaks)) {
breaks <- pretty(data, n = nlevels)
}
breakslen <- length(breaks)
colors <- do.call(palette, list(n = breakslen - 1))
if (rev.palette)
colors <- rev(colors)
if (scale) {
par(mfrow = c(1, 2))
nf <- layout(matrix(c(1, 2), 1, 2, byrow = TRUE), widths = c(4,
1))
}
par(las = 1, mar = c(5, 5, 3, 1))
image(xc, yc, pp, las = 1, asp = 1, breaks = breaks, col = colors,
axes = FALSE, ann = plot.axes, ...)
if (plot.axes) {
axis(1)
axis(2)
}
if (contour)
contour(unique(sort(xc)), unique(sort(yc)), pp, breaks = breaks,
add = TRUE)
if (scale) {
par(las = 1, mar = c(5, 1, 5, 5))
PlotImageScale(data, breaks = breaks, add.axis = FALSE,
axis.pos = 4, col = colors)
axis(4, at = breaks)
}
invisible(pp)
}
## generate a grid. At the moment it must be a cartesian square grid
## with number of cells a power of two, e.g. 128, 256, ...
@ -121,6 +72,54 @@ range(ax)
range(ay)
PlotField2 <- function (data, grid, nx, ny, contour = TRUE, nlevels = 12, breaks,
palette = "heat.colors", rev.palette = TRUE, scale = TRUE,
plot.axes = TRUE, ...)
{
if (!missing(grid)) {
xc <- unique(sort(grid$cell$XCOORD))
yc <- unique(sort(grid$cell$YCOORD))
nx <- length(xc)
ny <- length(yc)
if (!length(data) == nx * ny)
stop("Wrong nx, ny or grid")
}
else {
xc <- seq(1, nx)
yc <- seq(1, ny)
}
z <- matrix(round(data, 6), ncol = nx, nrow = ny, byrow = TRUE)
pp <- t(z[rev(seq(1, nrow(z))), ])
if (missing(breaks)) {
breaks <- pretty(data, n = nlevels)
}
breakslen <- length(breaks)
colors <- do.call(palette, list(n = breakslen - 1))
if (rev.palette)
colors <- rev(colors)
if (scale) {
par(mfrow = c(1, 2))
nf <- layout(matrix(c(1, 2), 1, 2, byrow = TRUE), widths = c(4,
1))
}
par(las = 1, mar = c(5, 5, 3, 1))
image(xc, yc, pp, las = 1, asp = 1, breaks = breaks, col = colors,
axes = FALSE, ann = plot.axes, ...)
if (plot.axes) {
axis(1)
axis(2)
}
if (contour)
contour(unique(sort(xc)), unique(sort(yc)), pp, breaks = breaks,
add = TRUE)
if (scale) {
par(las = 1, mar = c(5, 1, 5, 5))
PlotImageScale(data, breaks = breaks, add.axis = FALSE,
axis.pos = 4, col = colors)
axis(4, at = breaks)
}
invisible(pp)
}
PlotField2(log10(ax), nx=200, ny=200, contour = FALSE, xaxs="i", yaxs="i", nlevels=6, plot.axes = FALSE)
@ -323,125 +322,3 @@ PlotField2((out$Cl), nx=nx, ny=ny, contour = FALSE, nlevels=10,
dev.off()
##### debug, grid 200x100
nx <- 200
ny <- 100
alphamat <- matrix(1.1e-11, nrow = ny, ncol = nx)
data.table::fwrite(alphamat, "debug_alpha.csv", col.names = FALSE)
a <- read.table(
textConnection(
"H 1.11e+02 120.0,
O 5.55e+01 55.1,
Charge -2.0e-13 8.0e-17,
C(-4) 2.0e-16 2.0e-15,
C(4) 2.0e-03 0.2,
Ca 2.0e-01 0.03,
Cl 3.0e-01 0.5,
Fe(2) 1.4e-04 0.0002,
Fe(3) 1.3e-09 2.0e-08,
H(0) 6.0e-12 2.0e-11,
K 2.0e-03 1.0e-05,
Mg 1.0e-02 0.2,
Na 2.0e-01 0.3,
S(-2) 5.9e-10 0,
S(2) 8.3e-15 8.3e-12,
S(4) 2.1e-14 5.1e-14,
S(6) 1.6e-02 0.026,
Sr 4.5e-04 0.045,
U(4) 2.5e-09 2.5e-08,
U(5) 1.6e-10 1.6e-10,
U(6) 2.3e-07 1.0e-05"
))
vals <- t(a[, 2:3])
nams <- c("H", "O", "Charge", "CH4", "C", "Ca", "Cl", "Fe2", "Fe3",
"H0", "K", "Mg", "Na", "HS2", "S2", "S4", "S6","Sr", "U4",
"U5", "U6")
colnames(vals) <- nams
rownames(vals) <- c("IC", "BC")
vals
length(nams)
dim(vals)
t(vals)
ic <- matrix(rep(vals[1,], nx*ny), nrow = nx*ny, byrow = TRUE)
colnames(ic) <- nams
data.table::fwrite(ic, "debug_init.csv", col.names = TRUE)
dput(vals[2,])
out <- fread("debug_output.csv")
x11()
## cairo_pdf("debug_field_U6.pdf", width = 10, height = 6, family="serif")
# out <- fread("./debug_output.csv")
PlotField2(log10(out$U6), nx=nx, ny=ny, contour = FALSE, nlevels=10,
palette = "cm.colors", plot.axes = FALSE, rev.palette = FALSE)
##dev.off()
## cairo_pdf("debug_field_Na.pdf", width = 10, height = 6, family="serif")
out2 <- fread("./debug_output.csv")
PlotField2(out2$Na, nx=nx, ny=ny, contour = FALSE, nlevels=10,
palette = "topo.colors", plot.axes = FALSE, rev.palette = TRUE)
## dev.off()
out2$Na[seq(1, 200)]
range(out2$Na)
PlotField2(log10(out$U4), nx=nx, ny=ny, contour = FALSE, nlevels=10,
palette = "terrain.colors", plot.axes = FALSE)
out$U4[seq(50*200, 51*200)]
PlotField2(out2$Fe3, nx=nx, ny=ny, contour = FALSE, nlevels=10,
palette = "terrain.colors", plot.axes = FALSE)
out2$Na[seq(20*200, 21*200)]
out$Cl[seq(50*200, 51*200)]
PlotField2(log10(out$Fe2), nx=nx, ny=ny, contour = FALSE, nlevels=12,
palette = "terrain.colors", plot.axes = FALSE)
PlotField2((out$Cl), nx=nx, ny=ny, contour = FALSE, nlevels=10,
palette = "terrain.colors", plot.axes = FALSE)
dev.off()
library(Rcpp)
cppFunction("static const std::vector<int> gen_seq(int from, int to) {
int vsize = to - from + 1;
std::vector<int> vec(vsize);
for (int i = 0; i < vsize; i++) {
vec[i] = i+from;
}
return vec;
}")
gen_seq(24, 49)
cppFunction("static const std::vector<int> gen_vec(int elems) {
std::vector<int> vec(elems);
for (int i = 0; i < elems; i++) {
vec[i] = i;
}
return vec;
}")
gen_vec(20)

View File

@ -41,12 +41,14 @@ static const std::vector<int> gen_vec(int elems) {
return vec;
}
static const std::vector<int> gen_seq(int from, int to) {
int vsize = to - from + 1;
std::vector<int> vec(vsize);
for (int i = 0; i < vsize; i++) {
vec[i] = i+from;
static const std::vector<int> gen_vec_rev(int from, int to) {
int size = to - from+1;
std::vector<int> vec(size);
for (int i = from; i < to; i++) {
vec[i] = i;
std::cout << "i: " << i << "\n";
}
return vec;
}
@ -85,7 +87,6 @@ static bench_input barite_large_input = {
.iterations = 5
};
static bench_input surfex_input = {
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
.csv_alpha_x = "@SURFEX_BENCH@/surfex_alpha.csv",
@ -123,41 +124,30 @@ static bench_input surfex_input = {
.iterations = 20
};
static bench_input debug_input = {
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
.csv_alpha_x = "@SURFEX_BENCH@/surfex_alpha.csv",
.csv_alpha_y = "@SURFEX_BENCH@/surfex_alpha.csv",
.ncols = 200,
.nrows = 100,
.s_x = 0.02,
.s_y = 0.01,
.boundary = {.north_const = gen_vec(100),
.south_const = gen_seq(1, 19),
.east_const = {},
.west_const = gen_seq(50, 99),
.values = {120.0, // H
55.1, // O
8.0e-17, // Charge
2.0e-15, // CH4
0.2, // C
0.03, // Ca
0.5, // Cl
0.0002, // Fe2
2.0e-08, // Fe3
2.0e-11, // H0
1.0e-05, // K
0.2, // Mg
0.3, // Na
0, // HS2
8.3e-12, // S2
5.1e-14, // S4
0.026, // S6
0.045, // Sr
2.5e-08, // U4
1.6e-10, // U5
1.0e-05}}, // U6
.timestep = 86400,
.iterations = 20
};
#endif // _BENCH_DEFS_HPP

View File

@ -23,40 +23,29 @@ int main(int argc, char **argv) {
}
if (with_output) {
// std::cout << "BARITE_200 started with output... ";
// timings[0] = run_bench(barite_200_input, "barite_200_output.csv");
// std::cout << "Runtime: " << timings[0] << " [ms]\n";
std::cout << "BARITE_200 started with output... ";
timings[0] = run_bench(barite_200_input, "barite_200_output.csv");
std::cout << "Runtime: " << timings[0] << " [ms]\n";
// std::cout << "BARITE_LARGE started with output... ";
// timings[1] = run_bench(barite_large_input, "barite_large_output.csv");
// std::cout << "Runtime: " << timings[1] << " [ms]\n";
std::cout << "BARITE_LARGE started with output... ";
timings[1] = run_bench(barite_large_input, "barite_large_output.csv");
std::cout << "Runtime: " << timings[1] << " [ms]\n";
// std::cout << "SURFEX started with output... ";
// timings[2] = run_bench(surfex_input, "surfex_output.csv");
// std::cout << "Runtime: " << timings[2] << " [ms]\n";
std::cout << "DEBUG started with output... ";
timings[2] = run_bench(debug_input, "debug_output.csv");
std::cout << "SURFEX started with output... ";
timings[2] = run_bench(surfex_input, "surfex_output.csv");
std::cout << "Runtime: " << timings[2] << " [ms]\n";
} else {
std::cout << "BARITE_200 started with no output... ";
timings[0] = run_bench(barite_200_input);
std::cout << " Runtime: " << timings[0] << " [ms]\n";
// std::cout << "BARITE_200 started with no output... ";
// timings[0] = run_bench(barite_200_input);
// std::cout << " Runtime: " << timings[0] << " [ms]\n";
std::cout << "BARITE_LARGE started with no output... ";
timings[1] = run_bench(barite_large_input);
std::cout << "Runtime: " << timings[1] << " [ms]\n";
// std::cout << "BARITE_LARGE started with no output... ";
// timings[1] = run_bench(barite_large_input);
// std::cout << "Runtime: " << timings[1] << " [ms]\n";
// std::cout << "SURFEX started with no output... ";
// timings[2] = run_bench(surfex_input);
// std::cout << "Runtime: " << timings[2] << " [ms]\n";
std::cout << "DEBUG started with no output... ";
timings[2] = run_bench(debug_input);
std::cout << "SURFEX started with no output... ";
timings[2] = run_bench(surfex_input);
std::cout << "Runtime: " << timings[2] << " [ms]\n";
}
return EXIT_SUCCESS;

View File

@ -15,26 +15,6 @@
#include <Eigen/Eigen>
using TugType = double;
using RowMajorMat =
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
static inline std::vector<TugType>
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
if (mat.IsRowMajor) {
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
} else {
std::vector<TugType> out_vec(mat.size());
for (int i = 0; i < mat.rows(); i++) {
for (int j = 0; j < mat.cols(); j++) {
out_vec[i * mat.cols() + j] = mat(i, j);
}
}
return out_vec;
}
}
double run_bench(const bench_input &input, const std::string &output_file) {
std::vector<std::vector<double>> raw_data =
read_conc_csv<double>(input.csv_file_init, input.ncols, input.nrows);
@ -85,6 +65,11 @@ double run_bench(const bench_input &input, const std::string &output_file) {
tug::Simulation<TugType> sim(grid, boundary);
if (const char *out = std::getenv("OMP_NUM_THREADS")) {
int ompNumThreads = std::stoi(out, NULL);
sim.setNumberThreads(ompNumThreads);
}
sim.setTimestep(input.timestep);
sim.setIterations(input.iterations);

View File

@ -1,8 +1,29 @@
#ifndef _RUN_HPP
#define _RUN_HPP
#include <Eigen/Eigen>
#include <bench_defs.hpp>
using TugType = double;
using RowMajorMat =
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
double run_bench(const bench_input &input, const std::string &output_file = "");
static inline std::vector<TugType>
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
if (mat.IsRowMajor) {
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
} else {
std::vector<TugType> out_vec(mat.size());
for (int i = 0; i < mat.rows(); i++) {
for (int j = 0; j < mat.cols(); j++) {
out_vec[i * mat.cols() + j] = mat(i, j);
}
}
return out_vec;
}
}
#endif // _RUN_HPP