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 8fc5a7b commit 005e7a9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 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
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 005e7a9

Please sign in to comment.