确定可用于matlabpool的最大处理器数(MATLAB并行工具箱) [英] Determine the Maximum Number of Processors Available for matlabpool (MATLAB Parallel Toolbox)

查看:1010
本文介绍了确定可用于matlabpool的最大处理器数(MATLAB并行工具箱)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用parfor循环在MATLAB中编写一些代码,以加快一些乏味的计算.

I'm currently writing some code in MATLAB that uses the parfor loop to speed up some tedious calculations.

我的问题是,代码将在远程集群上运行,并且可以在4核,8核或12核计算机上运行(我不知道提前选择哪一个)...

My issue is that the code will be run on a remote cluster, and could be run on 4-core, 8-core or 12-core machines (I won't know which one in advance)...

我基本上需要一个代码片段,以使MATLAB能够确定可在matlabpool中使用的最大内核数.如果我们将此变量称为maxcores,那么我可以继续使用

I basically need a code snippet that will allow MATLAB to determine the maximum number of cores that can be used in matlabpool. If we call this variable maxcores, I can then go ahead and use

matlabpool('open',maxcores).

,以便确保可以使用所有可用的内核.

so that I can make sure that I am using all the cores that are available to me.

推荐答案

您可以通过feature('numCores')获取计算机上的内核数,该文件没有记载,但似乎不太可能损坏. ()

You can get the number of cores on the machine through feature('numCores'), which is undocumented but seems unlikely to break. (source)

有人声称getNumberOfComputationalThreads自R2007a起也可以使用,但不适用于我的R2012a.

Someone claims there that getNumberOfComputationalThreads also works since R2007a, but it doesn't on my R2012a.

这篇关于确定可用于matlabpool的最大处理器数(MATLAB并行工具箱)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆