在gcc编译器上编译多个程序时是否可以使用GPU加速? [英] Is it possible to use GPU acceleration on compiling multiple programs on a gcc compiler?

查看:2383
本文介绍了在gcc编译器上编译多个程序时是否可以使用GPU加速?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何方法或工具来应用GPU加速编译程序与GCC编译器?现在我创建了一个程序来迭代地编译给定的程序列表。这需要几分钟。我知道一些像Pyrit这样的程序,它有助于为预计算哈希应用GPU加速。

Is there any way or tool to apply GPU acceleration on compiling programs with GCC compiler? Right now I have created a program to compile the given list of programs iteratively. It takes a few minutes. I know of a few programs like Pyrit which helps to apply GPU acceleration for precomputing hashes.

如果没有这样的工具可用,请咨询是否使用OpenCL或任何否则重新编写我的代码。

If there are no such tools available, Please advice on whether to use OpenCL or anything else to reprogram my code.

我们非常感谢您的帮助。
谢谢。

Your Help will be highly appreciated. Thank you.

推荐答案

A。在命令式编程语言中,并且每个语句可以改变程序的状态。因此,分析翻译单元本质上是顺序的。

A. In an imperative programming language, statements are executed in sequence, and each statement may change the program's state. So analyzing translation units is inherently sequential.

例如:查看常量传播的工作原理 -

An example: Check out how constant propagation might work -

a = 5;
b = a + 7;
c = a + b + 9;

您需要先通过这些语句,然后才能确定分配给 b c 是编译时的常量。

You need to go through those statements sequentially before you figure out that the values assigned to b and c are constants at compile time.

块可以彼此并行地编译和优化。)

(However separate basic blocks may possibly be compiled and optimized in parallel with each other.)

B 除此之外,不同的遍还需要依次执行

B. On top of this, different passes need to execute sequentially as well, and affect each other.

一个例子:根据指令的时间表,你分配寄存器,然后你发现你需要把一个寄存器溢出到内存,所以您需要生成新的指令。这会改变计划。

An example: Based on a schedule of instructions, you allocate registers, then you find that you need to spill a register to memory, so you need to generate new instructions. This changes the schedule again.

所以你不能像'注册分配'和'调度'并行执行'通过'(实际上,我认为有一些文章,计算机科学家/数学家试图一起解决这两个问题,但不允许这样做)。

So you can't execute 'passes' like 'register allocation' and 'scheduling' in parallel either (actually, I think there are articles where computer scientists/mathematicians have tried to solve these two problems together, but lets not go into that).

此外,GPU特别不适合,因为:

Moreover, GPUs especially don't fit because:


  1. GPU适用于浮点数学。某些编译器不需要或使用太多(除非在程序中优化浮点运算)

  1. GPUs are good at floating point math. Something compilers don't need or use much (except when optimizing floating point arithmetic in the program)

GPU对SIMD很有用。即对多个输入执行相同操作。这也不是编译器需要做的事情。如果编译器需要例如优化几百个浮点运算(例如,程序员定义几个大的FP数组,为它们分配常量,然后写入),那么可能

GPUs are good at SIMD. i.e. performing the same operation on multiple inputs. This is again, not something a compiler needs to do. There may be a benefit if the compiler needs to, say, optimize several hundred floating point operations away (A wild example would be: the programmer defined several large FP arrays, assigned constants to them, and then wrote code to operate on these. A very badly written program indeed.)

除了并行化基本块的编译和流水线传递,在在C文件的编译的水平上没有太多的并行性已经。但是并行性是可能的,易于实现,并在更高级别不断使用。 例如,GNU Make 具有 -j = N 参数。这基本上意味着:只要它找到 N 独立作业(通常,编译一堆文件是 GNU Make 用于任何),它产生 N 进程(或 N 实例 gcc 并行编译不同的文件)。

So apart from parallelizing compilation of basic blocks and pipelining passes, there is not much parallelism to be had at the level of 'within compilation of a C file'. But parallelism is possible, easy to implement, and constantly used at a higher level. GNU Make, for example, has the -j=N argument. Which basically means: As long as it finds N independent jobs (usually, compiling a bunch of files is what GNU Make is used for anyway), it spawns N processes (or N instances of gcc compiling different files in parallel).

这篇关于在gcc编译器上编译多个程序时是否可以使用GPU加速?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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