多核Forth,有吗?

发布于 2024-10-31 15:44:28 字数 38 浏览 3 评论 0原文

是否存在这样的 Forth 实现,可以让您充分利用多核处理器?

Does such a implementation of Forth exists that allows you to take full advantage of multicore processors?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

最冷一天 2024-11-07 15:44:28

我最近意识到 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.

酒几许 2024-11-07 15:44:28

显然。我不太了解,参见多核处理器、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.

攒眉千度 2024-11-07 15:44:28

有一些在裸机上运行的 Forth 实现可以编译机器代码,如果您在开始打字之前做一些研究,您实际上会看到:

  1. Forth 是 Chuck Moore 自 1958 年以来使用的个人系统
  2. Forth是一种语言,一个编译器,一个操作系统,一个交互式调试器(在这里你可以理解它被“解释”),当你考虑到整个世界需要时,裸机作为 Chuck 的 Forth 系统会变得更好只需要运行 2 个寄存器、ALU 和程序计数器。 Forth 中的编程与你的操作系统可能使用的东西完全不同,所以我认为在判断什么是什么之前应该真正看看“裸机”甚至本机(是的,有本机堆栈机处理器)Forth。
  3. 正是这些“裸机”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:

  1. Forth was the personal system in use by Chuck Moore since 1958
  2. Forth is a language, a compiler, and operating system, an interactive debugger (where you get this idea of it being "interpreted") a bare-metal-as-Chuck-intended Forth system gets even better when you consider that this entire WORLD needs only 2 registers, and ALU, and a Program Counter to run. Programming in Forth is completely different than the stuff your operating system is likely made out of and so I think one should really look at "bare-metal" or even native (yes there are native stack machine processors) Forths before judging what is what.
  3. it was exactly these "bare-metal" Forth implementations what were used for decades and are still highly used today in embedded devices where your desktop OS should probably never go.
掀纱窥君容 2024-11-07 15:44:28

使用 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

半世晨晓 2024-11-07 15:44:28

一般来说,每种语言都具有与底层操作系统的完整接口,往往能够使用所有功能,包括并行分叉和运行部分功能的可能性。在 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:

 1024 THREAD-PET parallel 
: hello "Hello world!" CR ;
'hello parallel
 Hello world! OK

由于单词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:

 1024 THREAD-PET parallel 
: hello "Hello world!" CR ;
'hello parallel
 Hello world! OK

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文