- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
假设我有一个程序要在具有 32 个内核(64 个线程)的 linux 机器上运行,其中我只能使用 10 个内核(20 个线程)。所以我想在运行程序之前指定它。
我在谷歌上搜索并找到了 maxNumCompThreads
,但当我在装有 MATLAB 2016a、核心 i5(2 核心、4 线程)的机器上测试它时,它似乎不起作用.也就是说,当我执行以下任一操作时,feature('numCores')
得到相同的输出
maxNumCompThreads(1)
maxNumCompThreads(2)
maxNumCompThreads(4)
maxNumCompThreads('Automatic')
然后我尝试了 parpool
(每次我用 delete(gcp('nocreate'))
关闭当前的 parpool session )。运行 parpool(4)
时出现错误(我想我明白了为什么:parpool
接受了核心数并且自动启用了超线程并且测试机有只有 2 个物理内核)。所以我用 parpool(1)
和 parpool(2)
进行了测试。同样,feature('numCores')
的输出没有改变。
问题:对于上面第一段中描述的情况,什么是适合工作的正确工具? feature('numCores')
是查看适当规范是否生效的正确监控工具吗?
我在上面一直提到的相同 feature('numCores')
输出是:
MATLAB detected: 2 physical cores.
MATLAB detected: 4 logical cores.
MATLAB was assigned: 4 logical cores by the OS.
MATLAB is using: 2 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
编辑:当我在 linux 机器上运行 parpool(10)
时出现以下错误
Starting parallel pool (parpool) using the 'local' profile ... Error using parpo ol (line 103)
Couldn't interpret output from psname.sh: ""
Error in parpool_test_2016_10_03 (line 3)
parpool(10);
最佳答案
不,这不是正确的监控工具。请查看 feature('numthreads')
:
>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
4
>> feature('numthreads')
ans =
4
>> maxNumCompThreads(1)
ans =
4
>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
4
>> feature('numthreads')
ans =
1
一般来说,使用 feature
时要小心,因为它没有文档记录并且很容易在没有警告的情况下更改。看看this post和 this StackOverflow question有关功能
的更多信息。
关于MATLAB:控制核心/线程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39834042/
我是一名优秀的程序员,十分优秀!