我一直在编译“.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/