根据环境选择一个C二进制 [英] Choose a C binary according to the enviroment

查看:65
本文介绍了根据环境选择一个C二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经以产生更快的执行时间编译我的code。与特定的标志(-Os,-O2 -march =原生和他们的组合)。

I have compiled my code with specific flags (-Os, -O2, -march=native and their combinations) in order to produce a faster execution time.

但我的问题是,我没有在同一台机器始终运行(因为在我的实验室中有几种不同的机器)。有时候,我拥有了MacOS中运行,或者在Linux中(在这两种情况下使用不同的操作系统版本)。

But my problem is that I don't run always in the same machine (because in my lab there are several different machines). Sometimes I run within a MacOS, or within a Linux (in both cases with different OS versions).

我不知道是否有一种方法来确定取决于环境下,二进制运行(我的意思是高速缓存大小,CPU内核,以及有关具体的机器其他属性)的二进制文件将运行?换言之,根据所使用的特定机器如何选择(当程序加载)的速度更快的二进制($ P $不同目标二值的大小和指令集扩展pviously编译)?

I wonder if there is a way to determine which binary will be run depending on the environment where the binary will run (I mean cache size, cpu cores, and other properties about the specific machine)?. In other words, how to choose (when the program loads) the faster binary (previously compiled with different target binary sizes and instruction-set extensions) according to the specific machine used?

先谢谢了。

推荐答案

您可以根据于uname prebuilt一堆可执行文件并选择一个>。这个问题比较好的办法是选择一个工具链是能够执行JIT,安装时优化和/或运行时优化,如LLVM。

You may prebuilt a bunch of executables and choose one according to environment variable or things like uname. A Better approach to the problem is choose a toolchain that is able to perform JIT, install-time optimization and/or runtime optimization, like llvm.

这篇关于根据环境选择一个C二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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