低CPU和核心使用率在Repast Simphony Java运行期间。

huangapple go评论74阅读模式
英文:

Low CPU and Core Usage during Repast Simphony Java Run

问题

我正在使用Repast 2.7构建一个Agent-Based Model (ABM),我们的项目已经进展到一个阶段,我们正在使用更大的生产数据集来为我们的模型提供信息。

我注意到在我的32核工作站上,可执行文件只使用了3-12个核心;平均CPU使用率稳定在大约5.5%。看起来它应该使用更多的核心;或者充分利用正在使用的核心。我意识到这可能是天真的猜测。

Runtime.getRuntime().availableProcessors()

报告可用的核心数为32。

我想知道如何配置我的项目以利用更多的资源。我意识到高性能计算(HPC)版本是可用的;但是在追求另一个重写(我们是从AnyLogic转到Repast)之前,我想首先看看是否可以让模拟程序使用这台机器上所有可用的资源。

目前,每个"Tick"大约需要60秒,而数据集仅为最终版本的1/30,我们将在大约100次比较运行中进行数万次迭代。

感谢任何想法!

英文:

I am building an ABM in Repast 2.7 and we're getting to the point in the project where we are being delivered the larger production datasets for informing our model.

I'm noticing on my 32 core workstation that the executable is only using 3-12 cores; and the average cpu consumption is steady at about 5.5%. It seems as though it should be using either more cores; or maxing out the cores that it is using. I realize this is likely naïve speculation.

Runtime.getRuntime().availableProcessors()

Reports 32 cores are available.

I'm interested in knowing if and how to configure my project to utilize more resources. I realize that the HPC version is available; however I'd first like to see if I can get the simulation to use all of the available resources of this machine before pursuing another rewrite (we came to Repast from AnyLogic.)

Tick is currently taking around 60 seconds on a dataset that's only 1/30th the size of the final version and we're going to be doing 10s of thousands of iterations over approximately 100 comparative runs.

Thanks for any ideas!

答案1

得分: 2

Repast不提供模型代码的自动并行化。 Repast调度程序和代理代码在单个线程中运行,而显示将在单独的线程中运行,因此实际上只有一个CPU在执行模型逻辑的所有工作。 为了提高模型性能,我们推荐两个重要步骤:

  1. 分析代码,确定哪些部分是计算瓶颈。 Yourkit是我过去使用过的一个很好的Java分析工具。分析可以帮助确定代码的哪些部分效率低下和/或被非常频繁地调用。对经常使用的代码进行小的改进可以显著加快模型的速度。

  2. 通过显式使用Java线程池使模型并行化。如果您的代理逻辑仅依赖于先前步骤中代理和环境的状态,这是一个非常简单的过程。Repast的“Flock”演示是这个概念的一个简单示例。简而言之,您可以创建一个代理“管理器”,每个时钟周期都会计划它,管理器将按照CPU的数量划分代理,并且每个代理批次都会并行执行。

英文:

Repast doesn't provide automatic parallelization of the model code. The Repast scheduler and agent code runs in a single thread, and the displays will run in separate threads, so really only one CPU is doing all of the work of the model logic. To improve the model performance, we recommend two important steps:

  1. Profile the code to determine which parts are computational bottlenecks. Yourkit is a good Java profiler I've used in the past. Profiling can help determine if parts of the code are inefficient and/or called very frequently. Small improvements to frequently used code can speed up a model significantly.

  2. Parallelize your model by explicitly using Java thread pools. If your agent logic is dependent on the state of the agent and environment only during the previous step, this is a very straightforward process. The Repast "Flock" demo is a simple example of this concept. In short, you can create an agent "manager" that is scheduled for every tick, and the manager will divide up the agents by the number of CPUs and have each of the batches of agents execute in parallel.

huangapple
  • 本文由 发表于 2020年8月28日 02:40:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63622327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定