如何在运行时在Haskell中查找内核数量 [英] How to find the number of cores at runtime in Haskell

查看:112
本文介绍了如何在运行时在Haskell中查找内核数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Haskell有一种方法可以确定运行时机器上CPU核的数量吗? 是的,那里有是这样一种方法。来自Real World Haskell的代码: http://book.realworldhaskell.org /read/concurrent-and-multicore-programming.html

  import GHC.Conc(numCapabilities)

main = putStrLn $核心数量:++ show numCapabilities


Does Haskell have a method for determining the number of CPU cores present on a machine at runtime?

解决方案

Yes, there is such a method. Code from "Real World Haskell": http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html

import GHC.Conc (numCapabilities)

main = putStrLn $ "number of cores: " ++ show numCapabilities

这篇关于如何在运行时在Haskell中查找内核数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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