intel / intel-cmt-cat

User space software for Intel(R) Resource Director Technology
http://www.intel.com/content/www/us/en/architecture-and-technology/resource-director-technology.html
Other
693 stars 183 forks source link

membw: Fix compilation error when avx512 is not supported by gcc #157

Closed xiaochenshen closed 4 years ago

xiaochenshen commented 4 years ago

The membw tool depends on AVX-512 foundation instructions, which are supported in gcc version 4.9 or above. Building with older version gcc leads to compilation failure.

Add CFLAGs -mavx512f in Makefile only when gcc supports avx512. In addition, add gcc version check in avx512 related stores operations.

Signed-off-by: Xiaochen Shen xiaochen.shen@intel.com

Description

Fix https://github.com/intel/intel-cmt-cat/issues/156

NOTE:

Affected parts

Motivation and Context

Fix https://github.com/intel/intel-cmt-cat/issues/156 This issue breaks the building of intel-cmt-cat if avx512 is not supported by gcc.

How Has This Been Tested?

Test steps:

Without the fix:

# make
…
cc: error: unrecognized command line option ‘-mavx512f’
make[1]: *** [membw.o] Error 1
make[1]: Leaving directory `/home/xiaochen/intel-cmt-cat/tools/membw'
make: *** [all] Error 2

With the fix:

Case 1: CPU doesn't support AVX-512 (Broadwell server, gcc 4.8.5):

# ./membw -c 0 -b 50000 --write-avx512
No CPU support for AVX512 instructions!

# ./membw -c 0 -b 50000 --nt-write-avx512
No CPU support for AVX512 instructions!

Case 2: CPU supports AVX-512 but gcc doesn't support AVX-512 (Skylake server, gcc 4.8.5):

# ./membw -c 0 -b 50000 --write-avx512
- THREAD logical core id: 0,  memory bandwidth [MB]: 50000, starting...
No GCC support for AVX512 instructions!

exiting…

# ./membw -c 0 -b 50000 --nt-write-avx512
- THREAD logical core id: 0,  memory bandwidth [MB]: 50000, starting...
No GCC support for AVX512 instructions!

exiting...

Case 3: Both CPU and gcc support AVX-512 (Ice Lake server, gcc 8.3.1):
# ./membw -c 0 -b 50000 --write-avx512
- THREAD logical core id: 0,  memory bandwidth [MB]: 50000, starting...

# ./membw -c 0 -b 50000 --nt-write-avx512
- THREAD logical core id: 0,  memory bandwidth [MB]: 50000, starting...

Types of changes

Checklist:

xiaochenshen commented 4 years ago

I have rebased this PR against master branch for https://github.com/intel/intel-cmt-cat/pull/155 is merged.

xiaochenshen commented 4 years ago

Closed for this PR has been merged.