- 1 year ago
How to convert a CPU name to a string for -march & -mtune for MinGW?
To convert a CPU name to a string that can be used with the -march
and -mtune
options in MinGW, you can use the following table as a reference:
CPU Name | -march String | -mtune String |
---|---|---|
Intel Core i7 | corei7 | corei7 |
Intel Core 2 Duo | core2 | core2 |
Intel Pentium 4 | pentium4 | pentium4 |
AMD Athlon 64 | athlon64 | k8 |
AMD Opteron | opteron | k8 |
Note that the -march
option specifies the instruction set architecture to generate code for, while the -mtune
option specifies the CPU model to optimize code for. In some cases, the -march
and -mtune
options can be set to the same value, but in other cases they may differ depending on the specific CPU being targeted.
To specify a specific CPU, you would pass the appropriate -march
and -mtune
options to the MinGW compiler. For example, to compile code for an Intel Core i7 CPU, you would use the following options:
diff-march=corei7 -mtune=corei7
Similarly, to compile code for an AMD Opteron CPU, you would use the following options:
diff-march=opteron -mtune=k8
Note that the specific options you use may depend on the version of MinGW you are using and the specific CPU model you are targeting. You may need to consult the MinGW documentation or the CPU manufacturer's specifications for more information.