How do I get gfortran to generate architecture specific predefined macros?

53 views Asked by At

I want gfortran to generate architecture specific macros like __AVX__ and __AVX512F__ when it runs the preprocessor. If I run

echo | gfortran -march=tigerlake -dM -E -

I get all the predefined macros including the architecture specific ones printed to the screen. Now if I run

gfortran -c <somecode.F90> -march=tigerlake

gfortran runs the preprocessor with only a subset of the predefined macros. It seems like gfortran does not pass the -march=tigerlake flag to the preprocessor. This however, works with gcc.

See this long link https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:fortran,selection:(endColumn:20,endLineNumber:1,positionColumn:20,positionLineNumber:1,selectionStartColumn:20,selectionStartLineNumber:1,startColumn:20,startLineNumber:1),source:'%23if+defined+__AVX__%0A%23define+msg+%22Has+AVX%22%0A%23else%0A%23define+msg+%22Has+not+AVX%22%0A%23endif%0A%0Aprogram+AVX%0A++++implicit+none%0A++++print*,+msg%0Aend+program'),l:'5',n:'0',o:'Fortran+source+%231',t:'0')),k:31.01927062600148,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:gfortran132,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'1',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:fortran,libs:!(),options:'-cpp+-march%3Dtigerlake',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gfortran+13.2+(Editor+%231)',t:'0')),k:35.6473960406652,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gfortran+13.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gfortran+13.2+(Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4

I get the result "Has not AVX". I should get "Has AVX".

0

There are 0 answers