3

How can I set the value of the param 'Enable Enhanced Instruction Set' when compiling with msbuild from command line ?

enter image description here

1 Answers1

4

To realize this, it might be a complex but can be done. You only need to be with the help of a MSBuild property to transmit the value from msbuild command line into the EnableEnhancedInstructionSet Item matadata.

MSBuild can transmit the msbuild property rather then item metadata.

Solution

Modify these on your xxx.vcxproj file:

1) First set a default value Not Set for it.

<PropertyGroup>

<Instruction_Set>NotSet</Instruction_Set>

</PropertyGroup>


<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
      <EnableEnhancedInstructionSet>$(Instruction_Set)</EnableEnhancedInstructionSet>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>

2) Then, you can use msbuild command line like these to set it:

msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=StreamingSIMDExtensions

The values of the parameters are these:

The latter is what you need to use

SSE: StreamingSIMDExtensions

SSE2: StreamingSIMDExtensions2

AVX: AdvancedVectorExtensions

AVX2: AdvancedVectorExtensions2

AVX512: AdvancedVectorExtensions512

IA32: NoExtensions

Not Set: NotSet

You should use the value of it on the command line:

msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=xxx

===========================================

Update

I tested all the parameters under VS2019 successfully. And I wonder where goes wrong.

Please see these:

a) use SSE:

msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=StreamingSIMDExtensions

enter image description here

b) use AVX:

 msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=AdvancedVectorExtensions

enter image description here

c) use AVX512:

msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=AdvancedVectorExtensions512

enter image description here

d) use IA32:

 msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=NoExtensions

enter image description here

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • It works! but just one comment. Almost in the version of VS I'm running (2019) the values of the parameter are wrong. It accept values such as 'NotSet','AdvancedVectorExtensions2','StreamingSIMDExtensions2' etc.. – user6380706 Nov 18 '20 at 15:37
  • All values which I list are all tested in VS2019 and I make sure that they are all right. So I am curious where it goes wrong. You should use `-p:Instruction_Set=StreamingSIMDExtensions` or `-p:Instruction_Set=StreamingSIMDExtensions2` ....etc. – Mr Qian Nov 19 '20 at 02:12
  • The parameters I list are followed by the actual values to be entered. I have update my answer. See `update` and you can check it. – Mr Qian Nov 19 '20 at 02:25
  • If it helps, please do not forget to [accept it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) and if not, please feel free to let us know – Mr Qian Nov 19 '20 at 02:26
  • 1
    OK sorry, I misunderstood the way the params were written ;). At first I thought the bold text was the value of the param – user6380706 Nov 19 '20 at 10:00
  • It does not matter. Anyway, your issue has resolved by our joint efforts. I have added it into the answer. Have a nice day! – Mr Qian Nov 19 '20 at 10:04