Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
29 stars 12 forks source link

Number of cores should never be lower than 1 #1494

Closed Felixmil closed 3 weeks ago

Felixmil commented 3 weeks ago

When running on machines with only 1 core, RunSimulationOptions returns NumberofCores = 0 by default because it was computed this way:

ospsuiteEnv$numberOfCores <- function() {
  parallel::detectCores() - 1
}

Then, when running simulations, this error showed up:

2024-11-05T10:28:58.7863436Z Warning: Error in do.call: Type:    System.ArgumentOutOfRangeException
2024-11-05T10:28:58.7863808Z Message: MaxDegreeOfParallelism ('0') must be a non-zero value. (Parameter 'MaxDegreeOfParallelism')
2024-11-05T10:28:58.7863842Z Actual value was 0.
2024-11-05T10:28:58.7863861Z Method:  Void ThrowZero[T](T, System.String)
2024-11-05T10:28:58.7863876Z Stack trace:
2024-11-05T10:28:58.7863897Z    at System.ArgumentOutOfRangeException.ThrowZero[T](T value, String paramName)
2024-11-05T10:28:58.7863985Z    at System.ArgumentOutOfRangeException.ThrowIfZero[T](T value, String paramName)
2024-11-05T10:28:58.7864067Z    at System.Threading.Tasks.ParallelOptions.set_MaxDegreeOfParallelism(Int32 value)
2024-11-05T10:28:58.7864090Z    at OSPSuite.Core.Domain.Services.ConcurrencyManager.createParallelOptions(CancellationToken token, Int32 maximumNumberOfCoresToUse)
2024-11-05T10:28:58.7864111Z    at OSPSuite.Core.Domain.Services.ConcurrencyManager.<>c__DisplayClass3_0`1.<RunAsync>b__0()
2024-11-05T10:28:58.7864129Z    at System.Threading.Tasks.Task`1.InnerInvoke()
2024-11-05T10:28:58.7864153Z    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
2024-11-05T10:28:58.7864171Z --- End of stack trace from previous location ---