Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of cores should never be lower than 1 #1494

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

Felixmil
Copy link
Contributor

@Felixmil Felixmil commented Nov 5, 2024

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 ---

@Felixmil Felixmil requested review from msevestre and Yuri05 November 5, 2024 11:40
@Felixmil Felixmil changed the title Number of CPU should never be lower than 1 Number of cores should never be lower than 1 Nov 5, 2024
@Felixmil Felixmil merged commit dee2928 into main Nov 5, 2024
@Felixmil Felixmil deleted the at-least-one-cpu branch November 5, 2024 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants