pgcc(1)
π pgcc(1) π
okay so this is pgcc(1) from the General Commands Manual, and we are diving all the way in, bestie. No cap, this page is long, but it's giving βcompiler loreβ and we're gonna get through it together. π
β¨ NAME β¨
nvc β The NVIDIA ANSI and K&R C compiler. And yes, pgcc is literally an alias for nvc, so same energy, different name. π«Ά
π SYNOPSIS π
nvc [ -flag ]... sourcefile...
π¦ DESCRIPTION π¦
okay so pgcc is an alias for nvc. nvc is a C11 compiler for NVIDIA GPUs and AMD and Intel CPU. It supports C11, supports GPU parallel programming with OpenACC, and supports multicore CPU programming with OpenACC and OpenMP. nvc invokes the C compiler, assembler, and linker with options derived from its command line arguments. iconic behavior, honestly. π
Suffixes of source file names indicate the type of processing to be done:
.cβ C source; preprocess, compile.iβ C source after preprocessing; compile.sβ assembler source; assemble.Sβ assembler source; preprocess, assemble.oβ object file; passed to linker.aβ library archive file; passed to linker
If coinstalled with nvfortran, Fortran file suffixes are also recognized and compiled with the nvfortran compilers; see nvfortran and NVIDIA User's Guide. Other files are passed to the linker (if linking is requested) with a warning message. π«Ά
Unless one overrides the default action using a command-line option, nvc deletes the intermediate preprocessor and assembler files (see the options -c, -E, -P, and -Mkeepasm); if a single C program is compiled and linked with one nvc command, the intermediate object file is also deleted. Linking is the last stage of the compile process, unless you use one of the -c, -E, -P, or -S options, or unless compilation errors stop the whole process. π
π OPTIONS π
Options must be separate; -cs is different from -c -s. fr fr, do not smoosh them together. Here is a list of all options, grouped by type. More detailed explanations are in following sections. πΈ
π Overall Options π
---#-###-c-[no]defaultoptions--diag_errorarg--diag_remarkarg--diag_suppressarg--diag_warningarg--display_error_number-dryrun-drystdinc-dumpversion-echo--flagcheck-flags-fmax-errors=<n>--gcc-toolchain=path-help[=option]-Manno-Minform=level-Mint128-Mkeepasm-M[no]list-noswitcherror-o file-rc rcfile-S-show-silent-time-V-V<ver>-v--version-W[no]-deprecated-declarations-Werror-Wpedantic-W[no-]sign-compare-W[no-]unused-but-set-parameter-W[no-]unused-but-set-variable-W[no-]unused-parameter-W[no-]unused-variable-w-x language-x none-Wpass,option-Ypass,directory
π« Optimization Options π«
-alias=option-fast-f[no-]cx-limited-range-fastsse-fPIC-fpic-KPIC-Kpic-M[no]autoinline=option-Mcache_align-Mconcur=option-M[no]depchk-M[no]dse-Mextract=option-M[no]fma-M[no]frame-M[no]idiom-M[no]info=option-Minline=option-Minstrument=option-M[no]ipa=option-M[no]lre[=assoc|noassoc]-M[no]movnt-Mneginfo=option-Mnoopenmp-Mnosgimp-Mnovintr-Mpfi[=option]-Mpfo[=option]-M[no]pre-M[no]prefetch=option-Mprof=option-M[no]propcond-Mquad-Msafe_lastval-M[no]safeptr=option-M[no-]signed-zeros-M[no]stride0-M[no]unroll=option-M[no]unsafe_par_align-M[no]vect=option-M[no]zerotrip-mp[=option]-nomp-Olevel-pg
π΅οΈββοΈ Debugging Options π΅οΈββοΈ
-g-gopt-M[no]bounds-Mchkstk-Mcoff-Mdwarf2-Mdwarf3-Melf-Mnodwarf-[no]traceback
π§ Preprocessor Options π§
-C-Dmacro-dD-dI-dM-dN-E-Idirectory-include file-idirafter directory-isystem directory-iquote directory-M-Mcpp=[[no]comment|m|md|mm|mmd|mq:target|mt:target|suffix:suff]-MD-MM-MMD-MQ-MT-Mnostddef-Mnostdinc-Mpreprocess-P-Umacro-YI,directory-Yp,directory
π§ Assembler Options π§
-Wa,argument[,argument]...-Ya,directory
π Linker Options π
-acclibs--[no-]as-needed-Bdynamic-Bstatic-Bstatic-nvidia-Bsymbolic-c++libs-cudaforlibs-cudalib=libname-cudalibs-fortranlibs-g77libs-Ldirectory-llibrary-m-Mcudalib=libname-M[no]eh_frame-Mnostartup-Mnostdlib-M[no]rpath-Mmkl-nvmalloc-pgc++libs-pgf90libs-pthread-Rdirectory-r-rpath directory-s-shared-soname name-static-static-nvidia-uname--[no-]whole-archive-Wl,option[,option]...-Xlinker option[,option]...-YC,directory-Yl,directory-YL,directory-YS,directory-YU,directory
π£οΈ Language Options π£οΈ
-asmsuffix=suffix-B-c8x-c89-c9x-c99-c11-c1x-cuda=option-csuffix=suffix-fno-builtin-M[no]asmkeyword-M[no]builtin-M[no]dalign-Mdollar=char-Mfcon-M[no]llalign-Mlibsuffix=suffix-M[no]m128-Mobjsuffix=suffix-Mschar-M[no]signextend-M[no]single-Muchar-M[no]variadic_macros-Xa-Xc-Xs-Xt
π― Target-specific Options π―
-acc-noacc-gpu=option-K[no]ieee-Ktrap=option-march=target-m[no-]daz-ftz-M[no]daz-M[no]flushz-M[no]fpmisalign-M[no]fprelaxed=option-M[no]func32-Mgccbugs-M[no]longbranch-M[no]second_underscore-Mwritable-strings-mcmodel=small|medium-ta=target-target=option-tp=target
β οΈ Note: when source files are compiled using-g,-mp,-Mconcur,-Mipa, or-Mprofthe same option should be used when usingnvcto link the objects. π«Ά
π Overall Options π
Okay bestie, these are the big-picture switches β the ones that tell the driver what kind of mood itβs in. Letβs go.
--β Anything after this switch gets treated as a filename. But heads up: most tools will not allow a filename starting with a dash, so avoid those. π«Ά-#β Display the invocations of the compiler, assembler, and linker. These invocations are the command lines created bynvc.-###β Display invocations of the compiler, assembler, and linker, but do not execute them. Itβs giving βshow me the receipts, donβt actually run themβ energy.-cβ Skip the link step; compile and assemble only.-defaultoptions(default),-nodefaultoptionsβ Use (or donβt use) the default options set in site-specific or user-specificPREOPTIONSorPOSTOPTIONSdriver variables.--diag_errorargβ Override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number.--diag_remarkargβ Override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number.--diag_suppressargβ Override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number.--diag_warningargβ Override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number.--display_error_numberβ Display the error message number in any diagnostic messages that are generated. This one is lowkey useful for figuring out the error number you need when youβre overriding the severity of a diagnostic message. π-dryrunβ Use this option to display the invocations of the compiler, assembler, and linker but do not execute them.-drystdincβ Display the standard include directories without invoking the compiler.-dumpversionβ Display the shortened version of the compiler. For example,21.11or22.3.-echo [=go|stop]β Echo the command line flags and (by default) stop. This is useful when the compiler is invoked by a script.goβ Donβt stop after echoing the command line.stop(default) β Do stop after echoing the command line.
--flagcheckβ Donβt compile anything; just emit any messages for command-line switch errors. Return a success error code if there are no command-line switch errors.-flagsβ Display all validnvccommand-line options in alphabetical order.-fmax-errors=<n>β Specify the βmaximunβ (yes, spelled like that π) numbers of errors before terminating compilation.--gcc-toolchain=pathβ Specify gcc toolchain location using path to gcc directory or gcc executable. The argument can either be gcc root directory,<root directory>/bin, or the gcc executable itself.-help[=option]β Displays command-line options recognized bynvcon the standard output.nvc -help -otherswitchwill give help about-otherswitch. The default is to listnvccommand line options by group; options are:groupsβ Print out the groups into which the switches are organized.asmβ Print help for assembler command-line options.debugβ Print help for debugging command-line options.languageβ Print help for language-specific command-line options.linkerβ Print help for linker options.optβ Print help for optimization command-line options.otherβ Print help for any other command-line options.overallβ Print help for overall command-line options.phaseβ Print help for the known compiler phases.preproβ Print help for preprocessor command-line options.suffixβ Describe the known file suffixes.switchβ Print all switches in alphabetical order.targetβ Print help for target-specific command-line options.variableβ Show thenvcconfiguration; this is the same as-show.
-Mannoβ Produce annotated assembly files, where source code is intermixed with assembly language; implies-Mkeepasm.-Minform=levelβ Specify the minimum level of error severity that the compiler displays during compilation.fatalβ Instructs the compiler to display fatal error messages.file(default) /nofileβ Print out (donβt print out) the names of files as they are compiled; this is only active when there is more than one file on the command line.severeβ Instructs the compiler to display severe and fatal error messages.warnβ Instructs the compiler to display warning, severe and fatal error messages.informβ Instructs the compiler to display all error messages (inform,warn,severeandfatal).- The default is
-Minform=warn.
-Mint128β Enable extended integer types__int128andunsigned __int128.-Mkeepasmβ Keep the assembly file for each source file, but continue to assemble and link the program. This is mainly for use in compiler performance analysis and debugging.-Mlist,-Mnolist(default) β Create (donβt create) a listing file.-noswitcherrorβ Ignore unknown command line switches after printing a warning message; the default behavior is to print an error message and halt.-o fileβ Use file as the name of the executable program, rather than the defaulta.out. If used with-c,-P, or-S, and a single input file, file is used as the name of the object, preprocessor, or assembler output file.-rc rcfileβ Specifies the name of anvcstartup configuration file. If rcfile is a full pathname, then use the specified file. If rcfile is a relative pathname, use the file name as found in the$DRIVERdirectory.-Sβ Skip the assembly and link steps. Leave the output from the compile step in a file namedfile.sfor each file namedfile.c.-showβ Produce help information describing the currentnvcconfiguration.-silentβ Do not print warning messages. Same as-Minform=severe.-timeβ Print execution times for the various steps in the compiler itself.-Vβ Display version messages and other information.-V<ver>β If the specified version of the compiler is installed, that version of the compiler is invoked.-vβ Verbose mode; print out the command line for each tool before it is executed.--versionβ Display version messages and other information.-Wdeprecated-declarations,-Wno-deprecated-declarationsβ Emit or suppress warnings about use of functions, variables and types marked as deprecated using thedeprecatedattribute.-Werrorβ Turn all warning messages into errors.-Wpedantic,-pedanticβ Issue strict ANSI warnings.-Wsign-compare,-Wno-sign-compareβ Emit or suppress warnings when comparisons are made between signed and unsigned operands.-Wunused-but-set-parameter,-Wno-unused-but-set-parameterβ Emit or suppress warnings when parameters are set but unused. Implies-W[no]-unused-but-set-variable.-Wunused-but-set-variable,-Wno-unused-but-set-variableβ Emit or suppress warnings when variables are set but unused. Implies-W[no]-unused-but-set-parameter.-Wunused-parameter,-Wno-unused-parameterβ Emit or suppress warnings about unused parameters.-Wunused-variable,-Wno-unused-variableβ Emit or suppress warnings about local variables that are defined but are never referenced.-wβ Do not print warning messages.-x languageβ Specify explicitly the language for the input files (instead of choosing based on the file name suffix). Possible values for language are:ccppc++cpp-outputfFf95f95-cpp-inputf90F90f77f77-cpp-inputcufCUFasmASMassemblerassembler-with-cpp
-x noneβ Turn off language specification, so the input files are handled according to their suffixes.-Wpass,option[,option...]β Pass option to the specified pass. Each comma-delimited option is passed as a separate argument. The passes are:0β for the compiler,aβ for the assembler,iβ for the interprocedural analyzer, andlβ for the linker.
-Ypass,directoryβ Look in directory for pass pass, rather than in the standard area. The passes are:0β Search for the compiler executable in directory.aβ Search for the assembler executable in directory.Cβ Search for the compiler library in directory.iβ Search for the InterProcedural Analyzer (IPA) in directory.lβ Search for the linker in directory.Iβ Set the compilerβs standard include directory to directory. The standard include directory is set to a default value by the driver and can be overridden by this option.Lβ If the linker supports the-YLoption, then pass the option-YL,directoryto the linker. Otherwise, use directory as the standard library location.Sβ Search for the startup object files in directory.Uβ If the linker supports the-YUoption, then pass the option-YU,directoryto the linker. Otherwise this option is ignored.
β‘ Optimization Options β‘
-alias=optionβ Specifies whether to optimizing using ANSI C type-based pointer disambiguation rules. The options can be one of:ansiβ assume the ANSI C type-based pointer disambiguation rules apply β¨ this can enable better optimization in some cases β¨. The rules state that a load or store through a pointer of any type will not conflict with a load or store of a variable or through a pointer of a different type. This is the default with-O2and above.traditionalβ assume traditional C semantics apply. The compiler will assume that a load or store through any pointer might conflict with any variable or pointer dereference unless it can prove otherwise. This is the default with-O1and below, and when there is a type-cast pointer reference in the function.
-fastβ chooses generally optimal flags for the target platform π . Usenvc -fast -helpto see the equivalent switches. Heads up bestie: this sets the optimization level to a minimum of 2; see-O.-fcx-limited-rangeβ specify that complex division does not need range reduction.-fno-cx-limited-rangespecifies that complex division does need range reduction.-fcx-limited-rangeis the default setting at optimization level-Ofast.-fastsseβ chooses generally optimal flags for a processor that supports to vectorize for the SSE/AVX instructions π₯. Usenvc -fastsse -helpto see the equivalent switches.-fPICβ equivalent to-fpic; provided for compatibility with other compilers. (same vibe, different spelling, we love a supportive sibling)-fpicβ instructs the compiler to generate position-independent code which can be used to create shared object files (dynamically linked libraries) π.-KPICβ equivalent to-fpic; provided for compatibility with other compilers.-Kpicβ equivalent to-fpic; provided for compatibility with other compilers.-Mautoinline[option[,option...],-Mnoautoinline(default) β enable inlining of functions with theinlineattribute.-Mautoinlineis implied with the-fastswitch. The options are:levels:nβ inline up to n levels of function calls; the default is to inline up to 10 levels.maxsize:nβ only inline functions with a size of n or less. The size roughly corresponds to the number of statements in the function, though the correspondence is not direct π. The default is to inline functions with a size of 100 or less.totalsize:nβ stop inlining when this function reaches a size of n. The default is to stop inlining when a size of 8000 has been reached.
-Mcache_alignβ align unconstrained data objects of size greater than or equal to 16 bytes on cache-line boundaries β¨. An unconstrained object is a variable or array that is not a member of an aggregate structure or common block, is not allocatable, and is not an automatic array.-Mconcur[=option[,option,...]]β β οΈ heads up: this option has been deprecated and will be removed in a future release. It instructs the compiler to enable auto-concurrentization of loops. This also sets the optimization level to a minimum of 2; see-O. If-Mconcuris specified, multiple processors will be used to execute loops which the compiler determines to be parallelizable. When linking, the-Mconcurswitch must be specified or unresolved references will occur π. TheOMP_NUM_THREADSorNCPUSenvironment variables control how many processors will be used to execute parallelized loops. The options can be one or more of the following:allcoresβ use all available cores when the environment variablesOMP_NUM_THREADSandNCPUSare not set. This must be specified at link time.altcode:n,noaltcodeβ generate (don't generate) alternate scalar code for parallelized loops. The parallelizer generates scalar code to be executed whenever the loop count is less than or equal to n. Ifnoaltcodeis specified, the parallelized version of the loop is always executed regardless of the loop count.altreduction[:n]β generate alternate scalar code for parallelized loops containing a reduction. If a parallelized loop contains a reduction, the parallelizer generates scalar code to be executed whenever the loop count is less than or equal to n.assoc(default),noassocβ enable (disable) parallelization of loops with reductions.cncall,nocncall(default) β assume (don't assume) that loops containing calls are safe to parallelize. Also, no minimum loop count threshold must be satisfied before parallelization will occur, and last values of scalars are assumed to be safe.dist:blockβ parallelize with block distribution. Contiguous blocks of iterations of a parallelizable loop are assigned to the available processors.dist:cyclicβ parallelize with cyclic distribution. The outermost parallelizable loop in any loop nest is parallelized. If a parallelized loop is innermost, its iterations are allocated to processors cyclically. For example, if there are 3 processors executing a loop, processor 0 performs iterations 0, 3, 6, etc; processor 1 performs iterations 1, 4, 7, etc; and processor 2 performs iterations 2, 5, 8, etc π.innermost,noinnermost(default) β enable (disable) parallelization of innermost loops.levels:nβ parallelize loops nested at most n levels deep; the default is 3.
-Mdepchk(default),-Mnodepchkβ assume (don't assume) that potential data dependencies exist. π-Mnodepchkmay result in incorrect code; the-Msafeptrswitch provides a less dangerous way to accomplish the same thing.-Mdse,-Mnodse(default) β enable (disable) the dead store elimination optimization.-Mextract=[option[,option,...]]β run the subprogram extraction phase to prepare for inlining. The=lib:filenameoption must be used with this switch to name an extract library. See-Minlinefor more details on inlining. The options are:subprogram[,subprogram]β a non-numeric option not containing a period is assumed to be the name of a subprogram to be extracted.name:subprogram[,subprogram]β specifies the name of a subprogram or subprograms to be extracted.lib:directoryβ specifies the name of a directory to contain the extracted subprograms; this directory will be created if it does not exist.[size:]numberβ a numeric option is assumed to be a size. Functions containing number or less statements are extracted. If both number and function are specified, then functions matching the given name(s) or meeting the size requirements, are extracted.
-Mfma,-Mnofma(default) β generate (don't generate) fused multiply-add (FMA) instructions on the CPU and GPU for targets that support it π₯. FMA instructions are generally faster than separate multiply-add instructions, and can generate higher precision results since the multiply result is not rounded before the addition. Delaying rounding until after addition, however, may cause results to differ from those obtained with the unfused multiply-add instructions π¬. FMA instructions are enabled at optimization levels higher than-O1.-Mframe,-Mnoframe(default) β set up (don't set up) a true stack frame pointer for functions;-Mnoframeallows slightly more efficient operation when a stack frame is not needed, but some options override-Mnoframe(rude, but okay).-Midiom,-Mnoidiom(default) β enable loop idiom recognition. Memory copy, memory set, and memory zero loops are recognized and replaced with calls to their respective optimized versions β¨.-Minfo[=option[,option,...]],-Mnoinfo(default) β emit useful information tostderr. The options are:allβ includes optionsaccel,inline,ipa,loop,lre,mp,opt,par,stdpar,vect.accelβ emit information about accelerator region targeting.ftnβ emit Fortran-specific information.inlineβ emit information about functions extracted and inlined.intensityβ β οΈ this option has been deprecated and will be removed in a future version. Emit compute intensity information about loops.ipaβ emit information about the optimizations enabled by interprocedural analysis (IPA).loop|optβ emit information about loop optimizations. This includes information about vectorization and loop unrolling.lreβ emit information about loop-carried redundancy elimination.mpβ emit information about OpenMP parallel regions.parβ emit information about loop parallelization.pfoβ emit profile feedback information.time|statβ emit compilation statistics.stdparβ emit information about parallelization of C++ parallel algorithms and Fortran DO CONCURRENT loops.vectβ emit information about automatic loop vectorization.
With no options, -Minfo is the same as -Minfo=accel,ipa,loop,lre,mp,opt,par,stdpar,vect.
-Minline[=option[,option,...]]β pass options to the function inliner π§. The options are:lib:filename.extβ specify an inline library created by a previous-Mextractoption. Functions from the specified library are inlined. If no library is specified, functions are extracted from a temporary library created during an extract prepass.except:funcβ specifies which functions should not be inlined (sorry bestie, not you).
[name:]functionβ if the option isn't a number, bestie, it's a function name, periodt. And if you write it asname:with the colon? Then whatever comes after is always a function name, no guessing games πpragmaβ Fortran only π§βοΈ Inline only those procedures that have a!NVF$ INLINEpragma sitting on the source line immediately before the procedure'sSUBROUTINEorFUNCTIONstatement. Like a little VIP list for your subroutines π[maxsize:]numberβ a numeric option gets read as a size, duh. Functions of size number or less get inlined. And if you give it both a number and a function? Then it inlines the functions matching the given name(s) or meeting the size requirements. Both paths slay π«Άreshapeβ For Fortran, the default is to not inline subprograms with array arguments if the array shape doesn't match the shape in the caller. This overrides that default, so likeβ¦ go off, mismatch icon πsmallsize:numberβ always inline functions of size smaller than number, regardless of any other size limits. Tiny functions, main character energy β¨totalsize:numberβ stop inlining inside a function once that function's total inlined size reaches number. It's giving "we're full, no more guests at the function party" π
β¨ -Minstrument [=option] β¨
Generate extra code so you can get function-level instrumentation β yes, this option implies -Mframe. The option is:
functions(default) β literally the default, bestie π
β¨ -Mipa [=option[,option,...]], -Mnoipa (default) β¨
Turn on and specify options for InterProcedural Analysis (IPA). π Heads up though: IPA is not compatible with parallel make environments (like pmake, iykyk). Also, IPA sets the optimization level to a minimum of 2; peep -O. If you don't pass an option list at all, it's equivalent to -Mipa=const. The options are:
align,noalign(default) β enable (or disable) recognition when pointer targets are all cache-line aligned, which lets the compiler cook up better SSE code generation π₯arg,noarg(default) β remove (or don't remove) arguments replaced by-Mipa=ptr,const. Oh and-Mipa=noargimplies-Mipa=nolocalarg, no cap π«Άconst(default),noconstβ enable (or disable) propagation of constants across procedure calls. Constant queen behavior πf90ptr,nof90ptr(default) β enable (or disable) Fortran 90 pointer disambiguation across procedure calls π§fastβ picks generally optimal-Mipaflags for the target platform; runnvc -Mipa -helpto see the equivalent options. It's the "just pick for me" button βforceβ force all objects to recompile regardless of whether the IPA information changed. No skipping, bestie πglobals,noglobals(default) β analyze (or don't analyze) which globals get modified by procedure calls πinline:nβ figure out additional functions to inline, allowing up to n levels of inlining. The sub-suboptions are:except:procβ disables inlining of procedure proc πnopfoβ ignore any profile frequency information from-Mpfowhen choosing which functions to inline πreshape,noreshape(default) β enable (or disable) Fortran inlining with mismatched array shapes π¦
ipofileβ save IPA information in a.ipofile instead of the default, which is appending the info to the object file. Fancy πjobs:nβ use up to n jobs in parallel to reoptimize object files. Multitasking icon β¨keepobj(default),nokeepobjβ keep (or don't keep) the optimized object files, using file name mangling, so subsequent application builds recompile faster π₯libc,nolibc(default) β optimize calls to certain standard C library routines πlibinline,nolibinline(default) β allow (or don't allow) inlining from routines in libraries;-Mipa=libinlineimplies-Mipa=inlineπ«Άlibopt,nolibopt(default) β allow (or don't allow) recompiling and reoptimizing routines from libraries with IPA information π§βοΈlocalarg,nolocalarg(default) β enable (or disable) the feature that externalizes local variables so arguments can be replaced by-Mipa=ptr. And-Mipa=localargimplies-Mipa=argπmain:funcβ specify a function to serve as a global entry point; it may appear multiple times; it disables linking πͺptr,noptr(default) β enable (or disable) pointer disambiguation across procedure calls πpure,nopure(default) β detect (or don't detect) pure functions πΈquietβ don't print out messages about which files get recompiled at link time. Shhh π€«reaggregation,noreaggregation(default) β enable (or disable) global struct reaggregation. This can change the order of struct members, or split structs into multiple structs, to improve memory locality and cache utilization. Struct glow-up fr fr β¨requiredβ return an error condition if IPA is inhibited for any reason, instead of the default behavior of just linking without IPA optimization. It's giving "no plan B" π€safe:[function|library]β declares that the named function, or all functions in the named library, are safe; a safe procedure does not call back into the known procedures and does not change any known global variables. Without-Mipa=safe, any unknown procedures will cause IPA to fail πsafeall,nosafeall(default) β declares that all unknown functions are safe (or not safe); see-Mipa=safeπ‘οΈshape,noshape(default) β perform (or don't perform) Fortran 90 shape propagation π·summaryβ only collect IPA summary information when compiling; this prevents IPA optimization of this file, but still allows optimization for other files linked with this file. Selfless behavior, honestly π«Άvestigial,novestigial(default) β remove (or don't remove) functions that are not called. Bye to the flops nobody calls π
β¨ -Mlre[=assoc|noassoc], -Mnolre β¨
Enable (or disable) loop-carried redundancy elimination. The assoc option allows expression reassociation, and noassoc disallows expression reassociation. Pick your fighter π
β¨ -Mmovnt, -Mnomovnt β¨
Force (or disable) generation of nontemporal moves. Lowkey, -Mmovnt used with -fastsse can sometimes be faster than -fastsse alone π₯ By default, nontemporal moves are generated for loops with large loop counts β
β¨ -Mneginfo=option[,option...] β¨
Tells the compiler to spill the tea on why certain optimizations are not being performed π But like β use the -Minfo flag instead, bestie π
β¨ -Mnoopenmp β¨
When -mp is present, just ignore the OpenMP pragmas. Not me pretending they're not there π
β¨ -Mnosgimp β¨
When -mp is present, ignore the SGI parallelization pragmas. Also ghosted π»
β¨ -Mnovintr β¨
Do not generate vector intrinsic calls. Simple as that π¦
β¨ -Mpfi[=option] β¨
Generate profile feedback instrumentation; this includes extra code to collect run-time statistics that get used in a subsequent compile. Heads up: -Mpfi must also appear when the program is linked. When the program runs, a profile feedback file pgfi.out will be generated; peep -Mpfo for the other half of the story π The allowed options are:
indirect,noindirect(default) β enable (or disable) collection of indirect function call targets, which can be used for indirect function call inlining π
β¨ -Mpfo[=option[,option,...]] β¨
Enable profile feedback optimizations; there must be a profile feedback file pgfi.out in the current directory, and it has to contain the result of an execution of the program compiled with -Mpfi. The options are:
indirect,noindirect(default) β enable (or disable) indirect function call inlining; this requires apgfi.outfile generated from a binary built with-Mpfi=indirectπ«Άlayout(default),nolayoutβ enable (or disable) basic block layout to take advantage of instruction cache locality by keeping hot paths close together. Hot paths, hot girl summer π₯dir=directoryβ specify the directory containing thepgfi.outprofile feedback information file; the default is the current directory ποΈ
β¨ -Mpre, -Mnopre (default) β¨
Enable (or disable) the partial redundancy elimination optimization π
β¨ -Mprefetch[=option:n], -Mnoprefetch β¨
Add (or don't add) prefetch instructions for those processors that support them (Pentium 4, Opteron); -Mprefetch is default on Opteron; -Mnoprefetch is default on other processors π The options are:
distance:dβ set the fetch-ahead distance for prefetch instructions to d cache lines πn:nβ set the maximum number of prefetch instructions to generate in a loop to n π’ntaβ use theprefetchntainstruction πplainβ use theprefetchinstruction β¨t0β use theprefetcht0instruction βwβ allow the AMD-specificprefetchwinstruction π₯
β¨ -Mprof[=option[,option,...]] β¨
Set performance profiling options. Using these options makes the resulting executable create a performance profile that you can view and analyze with the PGPROF performance profiler π In the descriptions below, old-style profiling means compiler-generated source instrumentation. MPICH-style profiling means using instrumented wrappers for MPI library routines. The -Mprof options are:
dwarfβ generate limited DWARF symbol information sufficient for most performance profilers π§βοΈfuncβ perform old-style function level profiling πhwctsβ generate a profile using event-based sampling of hardware counters via the PAPI interface (PAPI must be installed β no PAPI, no party π) πlinesβ perform old-style line level profiling πtimeβ generate a profile using time-based instruction-level statistical sampling. This is literally the same energy as-pg, except the profile gets saved into a file calledpgprof.outinstead ofgmon.out. slay π«
okay so on Linux systems that have OProfile installed, PGPROF supports collecting performance data without recompiling. Using -Mprof=dwarf is highkey useful for this mode of profiling π§
-Mpropcond(default) /-Mnopropcondβ enable (or disable, if you pick thenoone) propagation of constant values that come from conditional branches with equality tests. little constants, big moves π-Mquadβ align large objects on quad-word boundaries. big things, tidy edges β¨-Msafe_lastvalβ so picture this: a scalar gets used after a loop, but it's not defined on every single iteration of that loop. By default the compiler is like "nope, not parallelizing that" π. This option tells the compiler it's safe to parallelize the loop anyway. go off, compiler π-Msafeptr[=option[,option,...]]/-Mnosafeptr(default) β overrides (or doesn't override) data dependence between C pointers, and between pointers and variables or arrays. β οΈ bestie, use this one with care β there's a real potential for code to be generated that gives you unexpected or incorrect results as defined by ANSI C. But when you use it properly, it has the potential to greatly enhance performance, especially for floating-point oriented loops. Different combinations of the options can be used and they interact appropriately πallβ all pointers are assumed not to overlap or conflict with other data objects;-Msafeptrwith no options implies-Msafeptr=all. all the things, independent π«Άarg|dummyβ C dummy arguments (pointers and arrays) get treated with the same copyin/copyout semantics as Fortran dummy arguments.auto|localβ C local or auto variables (pointers and arrays) are assumed not to overlap or conflict with other data objects, and they're independent. do your own thing, local girlie π¦globalβ C global or extern variables (pointers and arrays) are assumed not to overlap or conflict with other data objects and are independent.staticβ C static variables (pointers and arrays) are assumed not to overlap or conflict with other data objects and are independent. β
-Msigned-zeroes(default) /-Mno-signed-zerosβ toggles whether to honor (-Msigned-zeros) or ignore (-Mno-signed-zeros) issues associated with a signed0.0during optimization. zero but make it ~signed~ π-Mstride0/-Mnostride0(default) β generate (or don't generate) alternate code for a loop that contains an induction variable whose increment may be zero. what if the step is zero tho π-Munroll[=option[,option...]]/-Mnounroll(default) β invoke (or don't invoke, with-Mnounroll) the loop unroller. This also sets the optimization level to a minimum of2; check-Ofor that whole situation. The option is one of these:c:mβ tells the compiler to completely unroll loops with a constant loop count less than or equal tom, a supplied constant. If this value isn't supplied, themcount is set to1. And ifmis set to1, a compiler heuristic determines the maximum loop count at which such loops will be completely unrolled. unroll it all, idc πn:uβ tells the compiler to unrollutimes a single-block loop which is not completely unrolled, or has a non-constant loop count. Ifuisn't supplied, the unroller computes the number of times a candidate loop is unrolled.m:uβ tells the compiler to unrollutimes a multi-block loop which is not completely unrolled, or has a non-constant loop count. Ifuisn't supplied, the unroller computes the number of times a candidate loop is unrolled. π-Mnounrollβ instructs the compiler not to unroll loops. periodt. π
-Munsafe_par_align/-Mnounsafe_par_alignβ use (or don't use) aligned moves for array loads in parallelized loops, as long as the first element of the array is aligned; this is only effective with-Mvect=simd. it's "unsafe" because there are situations where the array elements allocated to some processors are not aligned π β hence the name, bestie.-Mvect [=option[,option,...]]/-Mnovect(default) β pass options to the internal vectorizer. This also sets the optimization level to a minimum of2, the equivalent of-O; for more info on optimization levels, see-O. If no option list is specified, then these vector optimizations are used:assoc,cachesize:c,simd:256, wherecis the actual cache size of the machine. β¨ the-Mvectoptions are β¨altcode(default) /noaltcodeβ enable (or disable) alternate code generation for vector loops, depending on stuff like array alignments and loop counts.fuse/nofuse(default) β enable (or disable) loop fusion, which combines adjacent loops into a single loop. two loops become one, iconic πprefetchβ use prefetch instructions in loops where profitable. getting ahead of the vibe check π¦simd[:{128|256|512}](default) /nosimdβ use vector SIMD instructions (AVX, AVX2, AVX512). The argument may be used to limit usage to 128-bit SIMD instructions. Specifying 512-bit SIMD instructions is only possible for target processors that support AVX512. 512-bit only if your CPU is that girl πuniform/nouniform(default) β perform the same optimizations in the vectorized and residual loops. Heads up: this may affect the performance of the residual loop. β
these next ones are also supported, but not recommended for use in new development, except by experienced users, and they may be phased out in future releases π«Ά
assoc(default) /noassocβ enable (or disable) certain associativity conversions that can change the results of a computation due to floating-point roundoff error differences. A typical optimization is changing the order of additions, which is mathematically correct but can be computationally different because of roundoff error. math said yes, float said hmm πcachesize:number(default=automatic) β tells the vectorizer, when it's doing cache tiling optimizations, to assume a cache size ofnumber.gather(default) /nogatherβ enable (or disable) vectorization of loops with indirect array references.idiom(default) /noidiomβ enable idiom recognition; this is an alternate form of-Midiom.levels:nβ set the maximum nest level of loops to optimize. how deep does the loop go π₯partialβ enable partial loop vectorization via innermost loop distribution.short/noshort(default) β enable (or disable) recognition of short vector operations that arise from scalar code outside of loops or within the body of loops.sizelimit[:number]/nosizelimit(default) β limit the size of loops that are vectorized; the default is to attempt to vectorize all loops. all loops, no cap πtile/notile(default) β enable (or disable) loop tiling to optimize for cache locality. π
-Mnovectdisables the vectorizer, and it's the default at-O0and-O1. π
-Mzerotrip(default) /-Mnozerotripβ include (or don't include) a zero-trip test for loops. Only use-Mnozerotripwhen all loops are known to execute at least once. like, you actually know bestie, for real π-mp[=option]β enable OpenMP pragmas and directives to explicitly parallelize regions of code so they can run on accelerator devices or on a multi-processor system. The options you're allowed to use are:gpuβ compile OpenMP directives for parallel execution on the GPU. GPU GIRLIE ERA π₯multicore(default) β compile OpenMP directives for parallel execution on the CPU.align/noalign(default) β modify (or don't modify) default loop iteration scheduling to align iterations with array references. The default is to use simple static scheduling.autopar(default) /noautoparβ enable loop autoparallelization ofomp loopconstructs. βomptβ link against an OMPT-enabled OpenMP library. π¦
-nompβ ignore OpenMP directives and do not link against OpenMP runtime libraries. openmp? don't know her π-O[level]β set the optimization level. If-Oisn't specified, then the default level is1if-gisn't specified, and0if-gis specified. If a number isn't supplied with-O, then the optimization level gets set to2. The optimization levels and their meanings are as follows: the optimization level lore π-O0β sets the optimization level to0. A basic block is generated for each statement. No scheduling is done between statements. No global optimizations are performed. chill mode, no thoughts head empty πΈ-O1β sets the optimization level to1. Scheduling within extended basic blocks is performed. No global optimizations are performed.-Oβ sets the optimization level to2, with no SIMD vectorization enabled. All level 1 optimizations are performed. In addition, traditional scalar optimizations such as induction recognition and loop invariant motion are performed by the global optimizer. glow up, but make it scalar β¨-O2β all-Ooptimizations are performed. In addition, more advanced optimizations are enabled, like SIMD code generation, cache alignment, and partial redundancy elimination. π₯-O3β all-O1and-O2optimizations are performed. In addition, this level enables more aggressive code hoisting and scalar replacement optimizations that may or may not be profitable. shoot your shot, compiler π-Ofastβ enables-O3,-Mfprelaxed,-Mstack_arrays,-Mno-nan,Mno-inf, and-fcx-limited-range. β οΈ note:-Mstack_arrayis disabled when both command line options-Ofastand-stdparare enabled. π«Ά
okay so picking up right where we left off in the optimization saga, these last two are lowkey iconic:
-O4β all the-O1,-O2, and-O3optimizations are performed. plus, hoisting of guarded invariant floating-point expressions is enabled. she's doing the most, and honestly? slay.-pgβ enablegprof-style sample-based profiling; implies-Mframe. yes bestie, profiling mode activated π
π DEBUGGING OPTIONS π
-gβ generate symbolic debug information. this also sets the optimization level to zero, unless a-Oswitch is present on the command line. symbolic debugging may give confusing results if an optimization level other than zero is selected. and using-O0means the generated code will be slower than code generated at other optimization levels. so likeβ¦ debug tea but make it a little slow π-goptβ generate symbolic debug information, without affecting optimizations. this may give confusing results when debugging with optimizations; it is intended for use with other tools that use the debug information. it's giving "for the other tools, not for your little debugging era" β¨-Mbounds,-Mnobounds(default) β add (don't add) array bounds checking. bounds checking is not applied to a subscripting pointer. important lil caveat, bestie π«Ά-Mchkstkβ check the stack for available space upon entry to and before the start of a parallel region. useful when many private variables are declared. stack check era π-Mcoffβ generate a COFF formatted object. retro lil object file vibe.-Mdwarf2β generate DWARF2 debug information with-g.-Mdwarf3β generate DWARF3 debug information with-g.-Melfβ generate an ELF formatted object. elf girlies rise πΈ-Mnodwarfβ don't add the default dwarf information.-traceback,-notraceback(default) β add debug information for runtime traceback.
πΈ PREPROCESSOR OPTIONS πΈ
-Cβ preserve comments in preprocessed C source files. keep the lil notes bestie π-Dname[=def]β define name to be def in the preprocessor. if def is missing, it is assumed to be empty. if the=sign is missing, then name is defined to be the string1. yes, exactly1, not a vibe, not a maybe.-dDβ print to standard output a list of the macros and their values as defined in the source files, along with the file name and line number where the definitions occur. full macro receipts π-dIβ print to standard output a list of all files included by the preprocessor, including the file name and line number where the include line occurred, and the full path of the included file. include forensic era π-dMβ print to standard output a list of all the macros and their values as defined in the source files, along with the file name and line number where the definitions occur, as well as predefined and command-line macros. the whole macro group chat, exposed π-dNβ like-dD, print to standard output a list of macro names, but not their values, as defined in the source files, along with the file name and line number where the definitions occur. names only, no values, mysterious β¨-Eβ preprocess each.cfile and send the result to standard output. no compilation, assembly, or linking is performed. just preprocessing and nothing else, periodt.-Idirectoryβ add directory to the compiler's search path for include files. for include files surrounded by< >, each-Idirectory is searched followed by the standard area. for include files surrounded by" ", the directory containing the file containing the#includedirective is searched, followed by the-Idirectories, followed by the standard area. search order lore, bestie π«Ά-include fileβ include the source code of the indicated file at the beginning of the compilation.-idirafter directoryβ add a directory to the end of the include file search path, after the standard include directories, and mark it as a system include directory. end of the line, but make it system β¨-isystem directoryβ same as-I, but mark the directory as a system directory.-iquote directoryβ add a directory to the beginning of the include file search path, and use it only when processing includes with quotes. quote-only behavior, we love a specialist π-Mβ generate a list of make dependences and print them to stdout.-MQand-MTare synonyms. noted, bestie π-Mcpp=[[no]comment|m|md|mm|mmd|mq:target|mt:target|suffix:suff]β only runs the preprocessor on the input file(s); by default, the output is written tofile.i, unless renamed with the-oswitch. the options are:comment,nocommentβ keep (don't keep) C-style comments in the preprocessed output.include:fileβ include this file before processing the source file.mβ print makefile dependencies to stdout, a la-M.mdβ print makefile dependencies tofile.d, a la-MD.mmβ print makefile dependencies to stdout, ignoring system includes (includes with angle braces), a la-MM.mmdβ print makefile dependencies tofile.d, ignoring system includes (includes with angle braces), a la-MMD.mq:'target'β print makefile dependencies to stdout, a la-MQ.mt:targetβ print makefile dependencies to stdout, a la-MT.lineβ include line numbers into the preprocessed output.suffix:suffβ when generating makefile dependencies, name the dependent filefile.suff; the default is to name the dependent filefile.o. suffix customization, cute π
-MDβ generate a list of make dependences and print them to the filefile.d, where file is the root name of the file under compilation.-MMβ generate a list of make dependences and print them to stdout; ignore system includes.-MMDβ generate a list of make dependences and print them to the filefile.d, where file is the root name of the file under compilation. ignore system includes.-MQβ generate a list of make dependences and print them to stdout.-MTβ generate a list of make dependences and print them to stdout.-Mnostddefβ do not predefine any macros to the preprocessor. no pre-made macros, we rawdog the preprocessor π-Mnostdincβ do not search in the standard location for include files when those files are not found elsewhere.-Mpreprocessβ run the preprocessor on assembler source files. assembler files get the preprocessor treatment too, fancy β¨-Pβ preprocess each file and leave the output in a file namedfile.ifor each file namedfile.c.-Unameβ remove the definition of the name macro in the preprocessor. undefine era, we love to see it π-YI,directoryβ change the standard include directory to directory.-Yp,directoryβ look in directory for the preprocessor executable.
π οΈ ASSEMBLER OPTIONS π οΈ
-Wa,option[,option...]β pass each comma-delimited option to the assembler. comma-separated little messages, delivered directly π«Ά-Ya,directoryβ look in directory for the assembler executable.
π LINKER OPTIONS π
okay bestie, this is the link-time era: every flag here is either passed straight to the linker or tells the driver what to feed it. no cap, these are all important π
-acclibsβ Link-time option to add the accelerator libraries to the link line.--as-needed,--no-as-neededβ Passed to the linker. Instructs the linker to only set theDT_NEEDEDflag for subsequent shared libraries, requiring those libraries at run time, if they are used to satisfy references.--no-as-neededrestores the default behavior.-Bdynamicβ Passed to the linker to specify dynamic binding.-Bstaticβ This option is the same as-static. Please refer to-staticfor details.-Bstatic-nvidiaβ This option is the same as-static-nvidia. Please refer to-static-nvidiafor details.-Bsymbolicβ Passed to linker; specify symbolic binding.-c++libsβ Link-time option to add the C++ runtime libraries, allowing mixed-language programming.-cudaforlibsβ Link-time option to add the CUDA Fortran runtime libraries, allowing mixed-language programming. Implies'-fortranlibs'.-cudalib[=libname[,libname...]]β Add CUDA-optimized libraries to the link line. When no option is specified the compiler will link all necessary CUDA-optimized libraries.-cudalibwill use the version of the library appropriate to the CUDA version being used. The libraries recognized arecublas,cublasmp,cufft,cufftmp,cufftw,curand,cusolver,cusolvermp,cusparse,cutensor,nccl,nvblas,nvshmem,nvtx3.-cudalibsβ This option has been deprecated please refer to-cudalib. Link-time option to add the CUDA runtime API library. π¨-fortranlibsβ Link-time option to add the Fortran runtime libraries, allowing mixed-language programming.-g77libsβ Link-time option which allows object files generated by GNUg77(orgcc) to be linked in tonvcmain programs.-Ldirectoryβ Passed to the linker; add directory to the list of directories in which the linker searches for libraries.-llibraryβ Passed to the linker; load the libraryliblibrary.afrom the standard library directory. See also the-Loption.-mβ Cause the linker to display a link map.-Mcudalib[=libname[,libname...]]β This option has been deprecated please refer to-cudalib. Add CUDA-optimized libraries to the link line. When no option is specified the compiler will link all necessary CUDA-optimized libraries. π¨-Meh_frame,-Mnoeh_frameβ Add (don't add) arguments to the link line to preserve the stack frame information for zero-cost exception handling frames. The default is-Mnoeh_frameunless changed in a site or user rcfile.-Mnostartupβ Do not link in the usual startup routine. This routine contains the entry point for the program.-Mnostdlibβ Do not link in the standard libraries when linking a program.-Mrpath(default),-Mnorpathβ The default is to add-rpathto the link line giving the directories containing the required runtime shared objects. Use-Mnorpathto instruct the driver not to add any-rpathswitches to the link line.-Mmklβ Add Intel's Math Kernel libraries to the link line. Requires that the environment variableMKLROOTbe set to the path to the local MKL installation (the part of the path that precedes'lib/<arch>').-nvmallocβ Use a custom host memory allocator.-pgc++libsβ Link-time option to add the C++ runtime libraries, allowing mixed-language programming.-pgf90libsβ Link-time option to add the PGF90 runtime libraries, allowing mixed-language programming.-pthreadβ Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.-Rdirectoryβ Passed to the linker; instructs the linker to hard-code the pathname directory into the search path for generated shared object files. Note that there cannot be a space betweenRand directory.-rβ Passed to the linker; generate a re-linkable object file.-rpath directoryβ Passed to the linker to add the directory to the runtime shared library search path.-sβ Passed to the linker; strip symbol table information.-sharedβ Passed to the linker. Instructs the linker to generate a shared object file (dynamically linked library). Implies-fpic.-soname nameβ Passed to the linker. When creating a shared object, instructs the linker to set the internalDT_SONAMEfield to the specified name.-staticβ Passed to the linker to specify static binding.-static-nvidiaβ Statically link in the NVIDIA runtime libraries, while using dynamic linking for the system libraries; implies-Mnorpath.-unameβ Passed to the linker; generate undefined reference.--whole-archive,--no-whole-archiveβ Passed to the linker. Instructs the linker to include all objects in subsequent archive files.--no-whole-archiverestores the default behavior.-Wl,option[,option]...,-Xlinker option[,option]...β Pass each comma-delimited option to the linker.-YC,directoryβ Look in directory for the standard compiler library files.-Yl,directoryβ Look in directory for the linker.-YL,directoryβ Change the standard library directory to directory.-YS,directoryβ Look in directory for the standard system startup object files.-YU,directoryβ Passed to the linker; change library search path.
πΈ LANGUAGE OPTIONS πΈ
these are the βwhat language am I speaking rnβ flags β so iconic for making the compiler understand your exact dialect π
-asmsuffix=suffixβ Define that a file with the given suffix is an assembly language file.-Bβ Allow C++-style comments in source code; these begin with the characters'//'and continue to the end of the current line. Such comments are stripped unless you specify the-Coption.-c8xβ Use the C89 standard as the C source language.-c89β Use the C89 standard as the C source language.-c9xβ Use the C99 standard as the C source language.-c99β Use the C99 standard as the C source language.-c11β Use the C11 standard as the C source language.-c1xβ Use the C11 standard as the C source language.-cuda[=option[,option...]β Enable CUDA Fortran; add CUDA include paths, and link with the CUDA runtime libraries.-cudais required on the link line. If-cudais used in compilation, it must also be used for linking. For target specific options, please refer to-gpu. For linking additional CUDA libraries (e.g. math libraries), please refer to-cudalib. Use the following sub-options to tailor the compilation of CUDA Fortran accelerator regions:charstringβ Enable limited support for character strings in GPU kernels.madconstβ Put Module Array Descriptors in CUDA Constant Memory.
-csuffix=suffixβ Define that a file with the given suffix is a C source file.-fno-builtinβ This option is the same as-Mno-builtin. Please refer to-Mno-builtinfor details.-Masmkeyword,-Mnoasmkeyword(default) β Allow (don't allow) theasmkeyword in C source code. The format is:asm("<text>").-Mbuiltin(default),-Mnobuiltinβ Compile (don't compile) with math subroutine builtin support, which causes selected math library routines to be inlined.-Mdalign(default),-Mnodalignβ Align (don't align) doubles in structures on 8-byte boundaries.-Mnodalignmay lead to data alignment exceptions.-Mdollar=charβ Set the character used to replace dollar signs in names to be char. Default is an underscore (_).-Mfconβ Treat non-suffixed floating-point constants asfloat, rather thandouble. This may improve the performance of single-precision code.-Mllalign(default),-Mnollalignβ Align (don't align) long longs orINTEGER*8in structures or common blocks on 8-byte boundaries.-Mllalignis the default.-Mlibsuffix=suffixβ Define that a file with the given suffix is an object library file.-Mm128,-Mnom128(default) β Recognize the datatypes__m128,__m128dand__m128i.-Mobjsuffix=suffixβ Define that a file with the given suffix is a binary object file.-Mschar(default) β Specify that thechartype is signed by default; see-Muchar.-Msignextend(default),-Mnosignextendβ Sign extend (don't sign extend) when a narrowing conversion overflows. For example, when-Msignextendis in effect and an integer containing the value65535is converted to ashort, the value of theshortwill be-1. ANSI C specifies that the result of such conversions are undefined.-Msingle,-Mnosingle(default) β Suppress (don't suppress) the ANSI-specified conversion offloattodoublewhen passing arguments to a function with no prototype in scope.-Msinglemay result in faster code when single precision is used a lot, but is non-ANSI compliant.-Mucharβ Specify that thechartype is unsigned by default; see-Mschar.-Mvariadic_macros,-Mnovariadic_macrosβ Allow (disallow) variadic macros. Variadic macros are enabled by default.-Xaβ ANSI mode: Specify that the compiled language should conform to all ANSI features.-Xcβ Conformance mode: Specify that the compiled language should conform to all ANSI features, but warnings may be produced about some extensions.-Xsβ Standard mode: specify that the compiled language should conform to K&R C. This also implies-ansi=traditional.-Xtβ Specify that the compiled language should conform to K&R C. The compiler may produce warnings for semantics where ANSI C and K&R C conflict. This also implies-ansi=traditional.
π TARGET-SPECIFIC OPTIONS π
-accβ Enable OpenACC pragmas and directives to explicitly parallelize regions of code for execution by accelerator devices. See the-gpuflag to select options specific to NVIDIA GPUs. The options are:autopar(default),noautoparβ turn loop autoparallelization on (or off) inside parallel constructs.gpu(default) β OpenACC directives get compiled so stuff runs in parallel on the GPU.hostβ OpenACC directives get compiled for serial execution on the host CPU. Yep, serial. One thing at a time, bestie.legacyβ shhh, no warnings about deprecated PGI accelerator directives. We don't talk about those.multicoreβ OpenACC directives get compiled for parallel execution on the host CPU.routinepar,noroutinepar(default) β infer the parallelism level clause (gang,worker,vector) in implicit routine directives.routineseq,noroutineseq(default) β compile every routine for the device, as if it had aroutine seqdirective.strictβ throw warnings when accelerator directives show up that don't adhere to the OpenACC standard. Snitch mode: activated.syncβ ignoreasyncclauses, and run every data transfer and kernel launch on the default sync queue.verystrictβ same energy asstrictbut it goes full main-character: abort compilation with a fatal error when an accelerator directive doesn't adhere to the OpenACC standard.wait(default),nowaitβ wait for each compute kernel to finish (or don't, live your truth β¨).
π
-noacc
Disable OpenACC directives entirely and don't link with OpenACC libraries. Bye bye accelerator land π¦
π₯ -gpu=option
Okay bestie, this is the big one β use these sub-options to tailor the compilation of target accelerator regions. Buckle up, there's a lot π
autocompareβ automatically compare CPU/GPU results. Accelerated code sections get run in redundant mode, and data gets compared whenever it would ordinarily be moved off the accelerator.- *
ccXY* β generate code for a device with compute capability XY. Multiple compute capabilities can be specified, and one version gets generated for each. By default the compiler detects the compute capability for each installed GPU. Use-help -gputo see the valid compute capabilities for your installation. ccallβ generate code for all compute capabilities supported for this target and by the selected CUDA Toolkit version. Overachiever behavior, honestly iconic πccnativeβ detects the visible GPUs on the system and generates code for them. If no device is available the default compute capability is used (cc50).ccall-majorβ compile for all major supported compute capabilities (does not include PTX for the highest major virtual architecture β see the`-gpu=[no]rdc`option for that support).- *
cudaX.Y* β use CUDA X.Y Toolkit compatibility, where installed. deepcopyβ enable Full Deepcopy support in OpenACC Fortran.fastmathβ enable the fast math library, which includes faster (but lower precision π¬) implementations of certain math and intrinsic functions. Speed vs. accuracy, the eternal struggle.flushz,noflushz(default) β enable (disable) flush-to-zero mode on the GPU.fma,nofmaβ generate (or don't) fused multiply-add operations on the GPU. This is enabled by default at optimization level-O1.implicitsections,noimplicitsections(default) β change (or don't change) array element references in OpenACC and OpenMP data clauses to array section references.interceptdeallocations,nointerceptdeallocationsβ intercept (or don't intercept) LIBC function calls (e.g.free) and call the corresponding CUDA memory deallocation version if the address is in pinned or managed memory, and the regular version otherwise.keepbinβ keep the generated CUDA binary, with a.cubinsuffix.keepgpuβ keep the generated CUDA GPU source files, with a.gpusuffix.keepltoirβ keep the generated GPU LTOIR files, with a.ltoirsuffix. Works only when`-gpu=lto`is enabled.keepptxβ keep the generated portable assembly files, with a.ptxsuffix.lineinfo,nolineinfo(default) β generate debugging line information.loadcache:[L1|L2]β generate code to cache global memory loads in theL1orL2hardware cache.ltoβ enable Device Link Ltime Optimization (Device LTO).- *
maxregcount:n* β set the maximum number of registers to use in the generated GPU code. managedβ allocate any dynamically allocated data in CUDA Managed memory. This option must appear in both the compile and link lines. This option may not be used with-gpu=pinned.interceptβ intercept LIBC function calls (e.g.free) and call their managed memory version if the address is in managed memory, regular version otherwise.
nomanagedβ do not allocate any dynamically allocated data in CUDA Managed memory. Use with-stdparto prevent that flag's implicit use of-gpu=managedwhen CUDA Managed memory capability is detected.nounifiedβ do not compile for CUDA Unified memory capability. Use with-stdparto prevent that flag's implicit use of-gpu=unifiedwhen CUDA Unified memory capability is detected.pinnedβ allocate any dynamically allocated data in CUDA Pinned host memory. This option must appear in both the compile and link lines. This option may not be used with-gpu=managed|unified.interceptβ intercept LIBC function calls (e.g.free) and call their pinned memory version if the address is in pinned memory, regular version otherwise.
mem:[mode]β select GPU memory mode from one of the following options:separate,managed,unified. This option cannot be combined with-gpu=pinned,gpu=managedor-gpu=unified.mem:separateβ all data are in separate CPU and GPU memories. Explicit memory copies are performed when data are accessed from both CPU and GPU.mem:managedβ allocate any dynamically allocated data in CUDA Managed Memory. Data that are not allocated dynamically are in separate GPU memory and are copied explicitly between CPU and GPU memories. This option must appear in both the compile and link lines.mem:unifiedβ compile for full CUDA Unified Memory capability, where system memory is accessible from the GPU. All variables in the CPU code are accessible from the GPU without explicit directives or attributes. This mode utilizes system and managed memory for dynamically allocated data unless explicit behavior is set through-gpu=mem:unified:[no]managedallocsubflags. This option must appear in both the compile and link lines.
mem:unified:managedalloc,mem:unified:nomanagedallocβ allocate (do not allocate) any dynamically allocated data in CUDA Managed Memory.mem:separate:pinnedalloc,mem:separate:nopinnedallocβ allocate (do not allocate) any dynamically allocated data in CUDA Pinned host memory.ptxinfoβ printptxasinformation.rdc(default),nordcβ generate (or don't generate) relocatable device code for separate compilation, and invoke the device linker before the host linker at the link step.redundantβ run accelerated code redundantly on the CPU. Implied byautocompare.safecacheβ allow variable-sized array sections in cache directives; the compiler assumes they fit into CUDA shared memory. Assumes. Bestie. Assumes π- *
sm_XY* β generate code for a device with compute capability XY. Multiple compute capabilities can be specified, and one version gets generated for each. By default the compiler detects the compute capability for each installed GPU. Use-help -gputo see the valid compute capabilities for your installation. stacklimit:limit(default), *nostacklimitβ β οΈ this option has been deprecated and will be removed in a future release. Give an error if the total stack size of a kernel or procedure exceeds *limit KBytes. The default isstacklimit:512.tripcount:hostβ calculate loop trip counts on the host for some compute constructs. This is the default behavior when-gpu=tripcountis not specified. Note that this behavior is not compliant with the OpenACC specification. To ensure compliance with the specification, please use-gpu=tripcount:device.tripcount:deviceβ calculate loop trip counts on the device for some compute constructs. Note that this behavior is compliant with the OpenACC specification, though it is not the default behavior. To explicitly enable the default behavior, please use-gpu=tripcount:host.tripcount:warn,tripcount:nowarnβ enable (disable) compile-time warnings when loop trip counts are calculated on the host instead of on the device.tripcount:check,tripcount:nocheckβ insert (or don't insert) runtime checks to ensure the trip count value calculated on the device matches the trip count value calculated on the host. To enable reporting of differences, set the environment variableNVCOMPILER_ACC_CHECK_TRIPCOUNT.unifiedβ compile for CUDA Unified memory capability, where system memory is accessible from the GPU. All variables in the CPU code are accessible from the GPU without explicit directives or attributes. This mode utilizes system and managed memory for dynamically allocated data unless explicit behavior is set through-gpu=[no]managed. Heads up, bestie: this option must appear in both the compile and link lines. This option may not be used with-gpu=pinned.interceptβ intercept LIBC function calls (e.g.free) and call their unified version if address is in unified memory, regular version otherwise.
unroll,nounrollβ automatically (do not) unroll inner loops. This is enabled by default at optimization level-O3.-Kieee,-Knoieee(default) β perform floating-point operations in strict conformance with the IEEE 754 standard. Some optimizations are disabled with-Kieee, and a more accurate math library is used. The default-Knoieeeuses faster but very slightly less accurate methods.-Ktrap=option[,option]...β controls the behavior of the processor when floating-point exceptions occur during program execution. Possible options include:denormβ trap on denormalized operands.divzβ trap on divide by zero.fpβ trap on floating-point exceptions.inexactβ trap on inexact result.invβ trap on invalid operation.none(default) β disable all traps.-Ktrap=inv,none,ovfimplies-Ktrap=ovf.ovfβ trap on floating-point overflow.unfβ trap on floating-point underflow.-Ktrapis only meaningful when compiling a C/C++ main function or Fortran main program.
-Ktrap=fp is shorthand for -Ktrap=divz,inv,ovf.
These options correspond to the processor's floating-point exception mask bits. Normally, the processor's exception mask bits are enabled, meaning floating-point exceptions are masked; the processor recovers from the exception and continues execution. If a mask bit is off (unmasked) and the corresponding exception occurs, execution terminates with a floating-point exception (Linux FPE signal).
-march=targetβ this option is the same as-tp. Please refer to-tpfor details.-m[no-]daz-ftzβ specify how denormals are handled by the processor at runtime.-mno-daz-ftzspecifies that denormal operands and results are honored. Shorthand for-Mnodaz -Mnoflushz.-mdaz-ftzdefault setting and specifies that denormal operands and results are treated as zero. Shorthand for-Mdaz -Mflushz.-Mdaz,-Mnodazβ enable [disable] mode to treat denormal (subnormal) floating-point operands as zero.-Mdazis the default setting for x86_64 and aarch64 processors.-Mflushz,-Mnoflushzβ enable [disable] setting floating-point denormal (subnormal) results to zero;-Mflushzis the default setting for x86_64 and aarch64 processors.-Mfpmisalign,-Mnofpmisalignβ allow (don't allow) vector arithmetic instructions with memory operands that are not aligned on 16-byte boundaries.-Mfprelaxed [=option[,option,...]],-Mnofprelaxed(default) β perform (don't perform) certain floating-point operations using relaxed precision when it improves speed. The options are:divβ perform divide using relaxed precision.intrinsicβ perform certain intrinsic functions using relaxed precision.order,noorderβ allow (don't allow) expression reordering, including factoring such as computinga*b+a*casa*(b+c).recipβ perform reciprocal operations using relaxed precision.rsqrtβ perform reciprocal square root (1/sqrt) using relaxed precision.sqrtβ perform square root using relaxed precision.
With no options, -Mfprelaxed will choose to generate relaxed precision code for those operations that generate a significant performance improvement, depending on the target processor.
-Mfunc32(default),-Mnofunc32β align (don't align) functions on 32 byte boundaries.-Mgccbugsβ match the behavior of certain bugs in gcc.-Mlongbranch,-Mnolongbranch(default) β enable (disable) long branches.-Msecond_underscore,-Mnosecond_underscore(default) β add (don't add) a second underscore to the name of a Fortran global if its name already contains an underscore. This option is useful for maintaining compatibility withg77, which adds a second underscore to such symbols by default.-Mwritable-stringsβ store string constants in the writable data segment.-mcmodel=small|mediumsmallβ limits the combined area for a user's object or executable to 4GB. The maximum code size is 2GB.mediumβ allows unrestricted data size. The maximum code size is 2GB.
-ta=targetβ this option has been deprecated, bestie β please refer to-acc.-ta=teslaβ this option has been deprecated please refer to-acc=gpuand-gpu.-ta=multicoreβ this option has been deprecated please refer to-acc=multicore.-ta=hostβ this option has been deprecated please refer to-acc=host.
-target=optionβ select the target for all parallel programming paradigms used (OpenACC, OpenMP, Standard Languages); possibilities are:gpuβ globally set the target device to an NVIDIA GPU.multicoreβ globally set the target device to the host CPU.
-tp=targetβ specify the type of the target processor. Issue:
nvc -help -tp
to display the list of recognized target processors.
π FILES
a.outβ executable output filefile.aβ library of object filesfile.cβ C source filefile.iβ C source file after preprocessingfile.ipaβ InterProcedural Analyzer (IPA) filefile.ipoβ InterProcedural Analyzer (IPA) filefile.oβ object filefile.sβ assembler source file.mynvcrcβ you may add custom switches or make other additions tonvcby creating a file named.mynvcrcin your home directory.
The installation of this version of the compiler resides in Basedir/Linux_x86_64/dev/; other versions may coexist in Basedir/Linux_x86_64/release/. Basedir is the root of the compiler installation directory, specified by the installer. The default is /opt/nvidia/hpc_sdk.
The compiler installation subdirectories are:
compilers/bin/β compiler and tool executables and configuration files (rcfiles).compilers/include/β compiler include files.compilers/lib/β runtime libraries and object files.comm_libs/β communication libraries, including NCCL and NVSHMEM.math_libs/β math libraries, including cuBLAS, cuTENSOR, cuSPARSE, cuFFT, cuSOLVER, and cuRAND.profilers/β profilers, including Nsight Compute and Nsight Systems.
π SEE ALSO
nvc++ (1), nvfortran (1), and the NVIDIA User's Guide.
π©Ί DIAGNOSTICS
The compiler produces information and error messages as it translates the input program. The linker and assembler may issue their own error messages.
Thatβs the whole pgcc(1) page, bestie β source/version pgcc(1), date September 2026. Stay slaying those compiler flags! π
β¨
π¦ where this page comes from
- arch rolling: nvhpc-compilers 26.9-1 Β· LicenseRef-NVIDIA-HPC-SDK
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms