Skip to content

Commit

Permalink
Add exception for non-parallelized code when NTHREADS > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreue16 committed Dec 11, 2024
1 parent 254041d commit 3b6d6f0
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/libcadet/SimulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,10 @@ namespace cadet
{
// Ensure numThreads >= 0
const int numThreads = paramProvider.getInt("NTHREADS");
#ifndef CADET_PARALLELIZE
if (numThreads != 1)
throw InvalidParameterException("Non-Parallelized version of CADET-Core is used, but field NTHREADS demands " + std::to_string(numThreads) + " threads. Please set NTHREADS to 1 or use the multithreaded version of CADET-Core.");
#endif // CADET_PARALLELIZE
_nThreads = std::max(numThreads, 0);
}
else
Expand Down
2 changes: 1 addition & 1 deletion test/ColumnTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ namespace column
setupJson["solver"]["CONSISTENT_INIT_MODE"] = pp.getInt("CONSISTENT_INIT_MODE");
if (pp.exists("CONSISTENT_INIT_MODE_SENS"))
setupJson["solver"]["CONSISTENT_INIT_MODE_SENS"] = pp.getInt("CONSISTENT_INIT_MODE_SENS");
setupJson["solver"]["NTHREADS"] = pp.getInt("NTHREADS");
//setupJson["solver"]["NTHREADS"] = pp.getInt("NTHREADS");
nlohmann::json timeIntegrator;
pp.pushScope("time_integrator");
timeIntegrator["ABSTOL"] = copy ? pp.getDouble("ABSTOL") : 1e-8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
},
"solver": {
"NTHREADS": 8,
"NTHREADS": 1,
"USER_SOLUTION_TIMES": [
0.0,
181.8181818181818,
Expand Down
2 changes: 1 addition & 1 deletion test/data/configuration_PBM_CSTR_growth_benchmark1.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
},
"solver": {
"NTHREADS": 8,
"NTHREADS": 1,
"USER_SOLUTION_TIMES": [
0.0,
181.8181818181818,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
},
"solver": {
"NTHREADS": 8,
"NTHREADS": 1,
"USER_SOLUTION_TIMES": [
0.0,
181.8181818181818,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
},
"solver": {
"NTHREADS": 8,
"NTHREADS": 1,
"USER_SOLUTION_TIMES": [
0.0,
181.8181818181818,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
},
"solver": {
"NTHREADS": 8,
"NTHREADS": 1,
"USER_SOLUTION_TIMES": [
0.0,
181.8181818181818,
Expand Down

0 comments on commit 3b6d6f0

Please sign in to comment.