GCC与多种架构兼容的最高指令集 [英] GCC highest set of instructions compatible with multiple architectures

查看:414
本文介绍了GCC与多种架构兼容的最高指令集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在由具有不同体系结构的计算机组成的群集上运行作业:
gcc -march = native -Q --help = target | grep-‘-march =’| cut -f3 给了我其中一个: broadwell haswell ivbridge sandybridge skylake

I am running jobs on a cluster composed of machines with different architectures: gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3 gives me one of these: broadwell, haswell, ivybridge, sandybridge or skylake.

可执行文件必须是相同的,所以我不能使用 -march = native ,但与此同时,这些架构有一些共同点(我认为它们都支持AVX吗?)。

The executable needs to be the same, so I cannot use -march=native but at the same time the architectures have things in common (I think they all support AVX?).

我知道 gcc (与Intel icc相反)不允许在单个可执行文件中使用多个架构。我想知道的是,是否有办法向 gcc 要求与上述所有架构兼容的最高指令集。

I am aware that gcc (contrary to Intel icc) does not allow for multiple archictures in a single executable. What I would like to know is if there is a way to ask gcc for the highest set of instructions compatible with all the architectures listed above.

gcc版本:8.1.1

gcc version: 8.1.1

推荐答案

评论建议我自己看一下交叉点在架构之间。以下bash脚本似乎可以完成这项工作。

Comments suggested me to look by myself at the 'intersection' between the architectures. The following bash script seems to do the job.

#!/usr/bin/env bash

archs=("broadwell" "haswell" "ivybridge" "sandybridge" "skylake")

for ar in ${archs[@]}; do
    gcc -march=$ar -Q --help=target | grep -- "  -m" > "$ar.log"
done

cp "${archs[0]}.log" all.log
for ar in ${archs[@]:1}; do
    join all.log "$ar.log" > tmp.log
    mv tmp.log all.log
done

cat all.log | grep "\[activé]" | grep -v "\[désactivé]" | cut -d' ' -f1 | tr '\n' ' '

(法语的计算机:activé => enabled ,désactivé => disabled)

(Computer in French: "activé" => "enabled", "désactivé" => "disabled")

输出为

-m128bit-long-double -m64 -m80387 -maes -malign-stringops -mavx -mcx16 -mfancy-math-387 -mfp-ret-in-387 -mfxsr -mglibc -mhard-float -mieee-fp -mlong-double-80 -mmmx -mpclmul -mpopcnt -mpush-args -mred-zone -msahf -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mstv -mtls-direct-seg-refs -mvzeroupper -mxsave -mxsaveopt

我希望所有体系结构都支持SSE和AVX。

As I expected all the architectures support both SSE and AVX.

这篇关于GCC与多种架构兼容的最高指令集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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