多核Forth,有吗?
是否存在这样的 Forth 实现,可以让您充分利用多核处理器?
Does such a implementation of Forth exists that allows you to take full advantage of multicore processors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我最近意识到 colorForth 这是摩尔先生的最新发明(不符合 ANS),并用于他的新的多核芯片。
它在单个芯片上具有 144 个小型计算机(并且没有时钟!),以实现高效率。
编辑:
实际上,colorForth 是芯片使用的 IDE。在芯片上运行的 (color)Forth 的风格称为 arrayForth。
I recently became aware of colorForth which is the latest invention from Mr Moore (not ANS compliant) and is used on his new multicore chips.
It features 144 small forth computers on a single chip (and no clock!) for high efficiency.
EDIT:
Actually, colorForth is the IDE used for the chips. The flavor of (color)Forth running on the chip is called arrayForth.
显然。我不太了解,参见多核处理器、FORTH编程以及之间的关系软件和芯片(2008-09-24 发布)。
您想要“充分利用”多核处理器。多核编程的借口是您需要性能(您只需一个 CPU 即可进行多线程)。
在这种情况下,我认为我不会使用 Forth,因为它本质上是一个解释器(是的,一个相当快的解释器)。
更糟糕的是,对于现代处理器来说,每个 Forth 字调度都是间接调用,很可能是管道中断,这确实会严重影响处理器性能,而且 Forth 字执行对堆栈元素而不是寄存器进行操作。因此,通过使用 Forth,您将放弃与 C 或 C++ 甚至 Fortran 相比的计算优势。这意味着您几乎必须在 Forth 中使用多个 CPU 才能匹配更传统的编码和编译语言的性能。为什么要从劣势开始呢?
那些想用 Python 做 MP 的人也因为同样的原因让我困惑。
Apparently. I don't know much about it, see Multicore processors, FORTH programming, and the relationship between software and silicon (published 2008-09-24).
You want to take "full advantage" of multicore processors. The excuse for multicore programming is that you need performance (you can do multithreaded with just one CPU).
In that case, I don't think I'd use Forth, as it is fundamentally an interpreter (yes, a fairly fast one).
Worse, for modern processors, each Forth word-dispatch being an indirect call is likely a pipeline break, which really slams processor performance, and Forth word-execution operates on stack elements instead of registers. So by using Forth, you are giving up computational advantage compared to C or C++ or even Fortran. What this means is that you are almost gauranteed to have to use more than one CPU with Forth to match the performance of a more traditionally coded and compiled language. Why start with a disadvantage?
The guys that want to do MP with Python puzzle me for the same reason.
有一些在裸机上运行的 Forth 实现可以编译机器代码,如果您在开始打字之前做一些研究,您实际上会看到:
There are Forth implementations that run on the bare-metal that DO compile machine code, and if you do a bit of research before you start typing you will see that in-fact:
使用 iForth 可以进行多核 Forth 编程。有适用于 Win7、Linux 和 OS X 的 32/64 位实现。 iForth 生成本机代码: http://home.iae.nl/users/mhx/i4faq.html
Multicore Forth programming is possible with iForth. There are 32/64 bit implementations that work on Win7, Linux, and OS X. iForth generates native code: http://home.iae.nl/users/mhx/i4faq.html
一般来说,每种语言都具有与底层操作系统的完整接口,往往能够使用所有功能,包括并行分叉和运行部分功能的可能性。在 Linux 下,这意味着您需要在 MS-Windows DLL 调用下进行系统调用的通用工具。在 Forth 的免费 ciforth 系列中,这在 linux 中称为 XOS:par1 par2 par3 N_### XOS。在 MS-Windows 中CALL[ ... ]CALL。
基于此系统调用,您可以拥有抢占式并行处理库,与 C 中可能实现的库没有太大区别。在 MS-Windows 下,您可以使用 DLL 调用,它们提供相同的功能,但它们在 Forth 上往往很难,因为它们已从 c 角度进行记录。
Ciforth 有一个库定义,使用 CREATE DOES>
使用字典 SPACE 创建一个线程。在线程中执行XT:
由于单词hello不包含无限循环,因此它会自动终止。
大多数商业程序都有类似的设施,但它不是标准化的,如果这就是您所追求的。
In general each language that have a full interface to an underling operating system, tend to be able to use all facilities, including the possibility to fork and run parts of this in parallel. Under linux that means you need a general facility for system calls, under MS-Windows DLL-calls. In the free ciforth family of Forth's this is called XOS in linux : par1 par2 par3 N_### XOS. In MS-Windows CALL[ ... ]CALL.
Based on this system call you can have pre-emptive parallel processing libraries, not much different from what is possible in C. Under MS-Windows you have DLL-calls, that provide the same facilities, but they tend to hard on Forth because they are documented for the c-perspective.
Ciforth has a library definitions, using CREATE DOES>
Create a thread with dictionary SPACE. Execute XT in thread:
As the word hello doesn't contain an infinite loop, it automatically terminates.
Most commercial programs have similar facilities, but it is not standardised, if that is what you're after.