compilation - 如何并行化可以在多台机器上分配任务的 "make"命令

标签 compilation parallel-processing linux-kernel makefile gnu-parallel

我一直在编译“.c/.c++”代码,使用“make”命令在 4 核机器上编译需要 1.5 小时。我还有 10 台机器可用于编译。我知道“make”中的“-j”选项,它以指定数量的线程分发编译。但是“-j”选项仅在当前机器上分配线程,而不是在网络中连接的其他 10 台机器上分配线程。

我们可以使用 MPI 或其他并行编程技术,但我们需要根据并行编程语言重写“MAKE”命令实现。

有没有其他方法可以利用其他可用的机器进行编译???
谢谢

最佳答案

是的,有:distcc .

distcc is a program to distribute compilation of C or C++ code across several machines on a network. distcc should always generate the same results as a local compile, is simple to install and use, and is often two or more times faster than a local compile.

Unlike other distributed build systems, distcc does not require all machines to share a filesystem, have synchronized clocks, or to have the same libraries or header files installed. Machines can be running different operating systems, as long as they have compatible binary formats or cross-compilers.

By default, distcc sends the complete preprocessed source code across the network for each job, so all it requires of the volunteer machines is that they be running the distccd daemon, and that they have an appropriate compiler installed.



它们的关键是你仍然保留你的单个 make,但是 gcc 会适本地安排文件(在本地运行预处理器、头文件……),但会安排通过网络编译为目标代码。

我过去曾使用过它,而且设置起来非常容易——而且对您的情况有帮助。

关于compilation - 如何并行化可以在多台机器上分配任务的 "make"命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32423666/

相关文章:

linux - 使用 Linux 可加载内核模块拦截系统调用(劫持)

linux - 生成多个作业以在四核处理器上构建内核?

c++ - cpp使用 vector 编译错误初始化二维数组

c - 目前有哪些方法可以让您在 C 中调用 Go 函数?

go - 什么是 golang 中的上下文寄存器?

unix - 使用 >> 将多个并行进程的输出通过管道传输到一个文件是否安全?

c - 中子输运模型的难点

c - 用户空间代码以什么顺序执行?

java - 当编译 Scala 程序中导入的 Java 库时,Scala 编译器是否调用 javac?

c++ - 扫描快速排序拆分