nvc(1)
๐ nvc โ the NVIDIA ANSI and K&R C compiler ๐
okay bestie, welcome to nvc(1) from the General Commands Manual ๐ this is the compiler that makes your GPU go brrr, and we're gonna read the whole thing together. grab a strawberry drink ๐
โจ NAME โจ
nvc โ The NVIDIA ANSI and K&R C compiler. that's the whole name, she's iconic and she knows it ๐
๐ธ SYNOPSIS ๐ธ
nvc [ -flag ]... sourcefile...
literally just: some flags, then some source files. that's the whole vibe โจ
๐ฆ DESCRIPTION ๐ฆ
so like, nvc is a C11 compiler for NVIDIA GPUs and AMD and Intel CPU โ yes she multitasks, main character energy fr ๐
- she supports C11 โ
- she supports GPU parallel programming with OpenACC ๐ฅ
- she supports multicore CPU programming with OpenACC and OpenMP ๐ซถ
and the way she works is: nvc invokes the C compiler, assembler, and linker with options derived from its command line arguments. like she's the manager and they're the team, periodt.
๐ source file suffixes (iykyk) ๐
the suffix at the end of your source file name tells her what kind of processing to do, no cap:
.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
โจ bonus lore: if she's coinstalled with nvfortran, then Fortran file suffixes are also recognized and compiled with the nvfortran compilers โ see nvfortran and NVIDIA User's Guide. and anything else? other files are passed to the linker (if linking is requested) with a warning message ๐ like she'll do it but she's judging you a little.
๐ the intermediate files situation ๐
listen close bestie, this part matters:
unless you override the default action using a command-line option, nvc deletes the intermediate preprocessor and assembler files โ see the options -c, -E, -P, and -Mkeepasm. and 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-Soptions, or unless compilation errors stop the whole process. so yeah, sometimes she stops early, and honestly? valid.
๐ฅ OPTIONS ๐ฅ
okay first rule of options club: Options must be separate โ -cs is different from -c -s. do not smoosh them together, she will not understand you ๐
here's the full roster, grouped by type, no summarising, we're doing all of them. 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, and this one's important: when source files are compiled using-g,-mp,-Mconcur,-Mipa, or-Mprof, the same option should be used when usingnvcto link the objects. like, don't forget to bring the same energy to the link step bestie, she's watching ๐
โจ Overall Options โจ
--โ bestie, everything after this switch is treated as a filename, periodt. That said, most tools will not let a filename start with a dash, so likeโฆ just avoid those? It's giving chaos for no reason. ๐-#โ shows you the invocations of the compiler, assembler, and linker. These invocations are the command lines thatnvcitself created โ so you get to peek behind the curtain. ๐-###โ same little show-and-tell as above (compiler, assembler, linker invocations), but it does not execute them. Pure vibes, zero consequences. โจ-cโ skip the link step entirely; compile and assemble only. Baby steps, we're not linking today. ๐-defaultoptions(default) /-nodefaultoptionsโ use (or don't use) the default options that live in the site-specific or user-specificPREOPTIONSorPOSTOPTIONSdriver variables. Yes, those are real variable names, keep them exactly like that. ๐ซถ--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. (The manpage glues the option and its arg together like this โ iconic formatting, honestly.) ๐ธ--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. Yes it's the same sentence three times, no I did not make the rules. ๐--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. That's four diag options, all accounted for, don't come for me. ๐ญ--display_error_numberโ shows the error message number inside any diagnostic messages that get generated. Lowkey the useful part: you use this to figure out which error number to plug into the severity-overriding options above. iykyk. ๐ฅ-dryrunโ display the invocations of the compiler, assembler, and linker but do not execute them. Rehearsal mode. ๐ญ-drystdincโ display the standard include directories without invoking the compiler. Just the receipts, no compiling. ๐งพ-dumpversionโ display the shortened version of the compiler. Like21.11or22.3. Short and slay. โญ-echo [=go|stop]โ echo the command line flags and (by default) stop. Super handy 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 at all; just emit any messages for command-line switch errors. Returns a success error code if there are no command-line switch errors. Vibe check, but for your flags. โ-flagsโ display all validnvccommand-line options in alphabetical order. Aesthetic. ๐-fmax-errors=<n>โ specify the maximum number of errors before terminating compilation. Yes bestie, there's a limit, we can't be here forever. ๐--gcc-toolchain=pathโ specify the gcc toolchain location usingpathto the gcc directory or the gcc executable. The argument can either be the gcc root directory,<root directory>/bin, or the gcc executable itself. Flexible queen. ๐-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. Theoptions 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 the source code is intermixed with the assembly language; implies-Mkeepasm. It's giving study guide for your own code. ๐-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, severe and fatal).
The default is -Minform=warn. (Yes, file is also marked default up there โ both facts are in the page, I'm not frenching the timeline, I'm just reporting it. ๐)
-Mint128โ enable extended integer types__int128andunsigned __int128. Big numbers, bigger energy. ๐ข-Mkeepasmโ keep the assembly file for each source file, but continue to assemble and link the program. Mainly for compiler performance analysis and debugging, so likeโฆ a niche icon, but an icon. ๐ง-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. Choose your fighter. โ๏ธ-o fileโ usefileas the name of the executable program, rather than the defaulta.out. If used with-c,-P, or-S, and a single input file,fileis used as the name of the object, preprocessor, or assembler output file. One flag, several moods. ๐-rc rcfileโ specifies the name of anvcstartup configuration file. Ifrcfileis a full pathname, then use the specified file. Ifrcfileis a relative pathname, use the file name as found in the$DRIVERdirectory. Remember that env var, it's important. ๐-Sโ skip the assembly and link steps. Leave the output from the compile step in a file namedfile.sfor each file namedfile.c. Assembly-only era. โจ-showโ produce help information describing the currentnvcconfiguration. ๐ช-silentโ do not print warning messages. Same as-Minform=severe. Shhh. ๐คซ-timeโ print execution times for the various steps in the compiler itself. For when you need to know who's slow. โฑ๏ธ-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. Time travel, but legal. ๐ฐ๏ธ-vโ verbose mode; print out the command line for each tool before it is executed. Nosy in the best way. ๐--versionโ display version messages and other information. Same energy as-V, different spelling. ๐-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. No mercy, no notes. ๐ฅ-Wpedantic/-pedanticโ issue strict ANSI warnings. The hall monitor of flags. ๐-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. They're mutually implying, it's a whole thing. ๐ซ-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. Poor things. ๐ญ-wโ do not print warning messages. (Different from-silentup there, so don't merge them in your head.) ๐-x languageโ specify explicitly the language for the input files (instead of choosing based on the file name suffix). Possible values forlanguageare: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. Back to autopilot. ๐ผ-Wpass,option[,option...]โ passoptionto 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 indirectoryfor passpass, rather than in the standard area. The passes are:0โ search for the compiler executable indirectory.aโ search for the assembler executable indirectory.Cโ search for the compiler library indirectory.iโ search for the InterProcedural Analyzer (IPA) indirectory.lโ search for the linker indirectory.Iโ set the compiler's standard include directory todirectory. 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, usedirectoryas the standard library location.Sโ search for the startup object files indirectory.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 optimize 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, which can unlock better optimization in some cases ๐ฅ. The rules say: 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 instead. The compiler assumes 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 also whenever there's a type-cast pointer reference in the function.-fastโ picks generally optimal flags for the target platform โจ. Runnvc -fast -helpto see the equivalent switches. Heads up: this sets the optimization level to a minimum of2; see-O.-fcx-limited-rangeโ says complex division does not need range reduction.-fno-cx-limited-rangesays complex division does need range reduction.-fcx-limited-rangeis the default at optimization level-Ofast๐ .-fastsseโ picks generally optimal flags for a processor that supports vectorizing for the SSE/AVX instructions ๐. Runnvc -fastsse -helpto see the equivalent switches.-fPICโ equivalent to-fpic; it's here for compatibility with other compilers ๐ซถ.-fpicโ tells the compiler to generate position-independent code, which you can use to create shared object files (that's dynamically linked libraries, bestie) ๐.-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) โ enables inlining of functions with theinlineattribute ๐ธ.-Mautoinlineis implied with the-fastswitch. The options are:levels:nโ inline up tonlevels of function calls; the default is to inline up to10levels.maxsize:nโ only inline functions with a size ofnor 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 of100or less.totalsize:nโ stop inlining when this function reaches a size ofn. The default is to stop inlining when a size of8000has been reached.
-Mcache_alignโ aligns unconstrained data objects of size greater than or equal to16bytes 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. Very demure, very mindful.
โ ๏ธ -Mconcur is deprecated and will be removed in a future release. Like, seriously, don't build your whole personality on it ๐ญ.
-Mconcur[=option[,option,...]]โ instructs the compiler to enable auto-concurrentization of loops ๐ฅ. This also sets the optimization level to a minimum of2; 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 ton. 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 ton.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 are3processors executing a loop, processor0performs iterations0,3,6, etc; processor1performs iterations1,4,7, etc; and processor2performs iterations2,5,8, etc.innermost,noinnermost(default) โ enable (disable) parallelization of innermost loops.levels:nโ parallelize loops nested at mostnlevels deep; the default is3.
-Mdepchk(default),-Mnodepchkโ assume (don't assume) that potential data dependencies exist. Heads up bestie:-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.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 containingnumberor less statements are extracted. If bothnumberandfunctionare 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.-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. She ate.-Minfo[=option[,option,...]],-Mnoinfo(default) โ emit useful information to stderr ๐. 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โ 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 FortranDO CONCURRENTloops.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.
[name:]functionโ if it's not a number, it's a function name, periodt. And if you writename:, then whatever comes after is always the name of a function, no guessing.pragmaโ Fortran Only, bestie: inline only those procedures that have a!NVF$ INLINEpragma sitting on the source line immediately before the procedure'sSUBROUTINEorFUNCTIONstatement. Iconic behavior honestly.[maxsize:]numberโ if it is a number, it's a size. Functions of size number or less get inlined. And if you give both number and function, then functions matching the given name(s) or meeting the size requirements get inlined. Both lanes open ๐reshapeโ for Fortran, the default is to not inline subprograms with array arguments when the array shape doesn't match the shape in the caller. This here overrides that default. Rebel move.smallsize:numberโ always inline functions of size smaller than number, regardless of any other size limits. Tiny functions, immediate VIP access โจtotalsize:numberโ stop inlining inside a function once that function's total inlined size reaches the number you specified. Cutoff point, no cap.
-Minstrument [=option]โ generates extra code so you can do function-level instrumentation. Heads up: this option implies-Mframe. The option isfunctions(default).-Mipa [=option[,option,...]],-Mnoipa(default) โ turns on and configures InterProcedural Analysis (IPA). Big note: IPA is not compatible with parallel make environments (e.g.,pmake). Also, IPA sets the optimization level to a minimum of 2 โ see-O. If you give no option list at all, it's equivalent to-Mipa=const. The options are:align,noalign(default) โ enable (disable) recognition when pointer targets are all cache-line aligned, which lets the compiler make better SSE code generation. Aligned girlies win ๐ธarg,noarg(default) โ remove (don't remove) arguments that got replaced by-Mipa=ptr,const. FYI-Mipa=noargimplies-Mipa=nolocalarg.const(default),noconstโ enable (disable) propagation of constants across procedure calls.f90ptr,nof90ptr(default) โ enable (disable) Fortran 90 pointer disambiguation across procedure calls.fastโ picks the generally optimal-Mipaflags for the target platform; runnvc -Mipa -helpto see the equivalent options. The lazy-girl autopilot ๐forceโ force all objects to recompile regardless of whether the IPA information changed.globals,noglobals(default) โ analyze (don't analyze) which globals get modified by procedure calls.inline:nโ find more functions to inline, allowing up to n levels of inlining. Additional suboptions are:except:procโ disables inlining of procedure proc. Not you, bestie ๐nopfoโ ignore any profile frequency information from-Mpfowhen choosing which functions to inline.reshape,noreshape(default) โ enable (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.jobs:nโ use up to n jobs in parallel to reoptimize object files. Multitasking queen ๐keepobj(default),nokeepobjโ keep (don't keep) the optimized object files, using file name mangling, to reduce recompile time in subsequent application builds.libc,nolibc(default) โ optimize calls to certain standard C library routines.libinline,nolibinline(default) โ allow (don't allow) inlining from routines in libraries;-Mipa=libinlineimplies-Mipa=inline.libopt,nolibopt(default) โ allow (don't allow) recompiling and reoptimizing routines from libraries with IPA information.localarg,nolocalarg(default) โ enable (disable) the feature that externalizes local variables so arguments can be replaced by-Mipa=ptr. Note:-Mipa=localargimplies-Mipa=arg.main:funcโ specify a function to serve as a global entry point; may appear multiple times; this disables linking.ptr,noptr(default) โ enable (disable) pointer disambiguation across procedure calls.pure,nopure(default) โ detect (don't detect) pure functions.quietโ don't print out messages about which files are being recompiled at link time. Silence is golden, honestly.reaggregation,noreaggregation(default) โ enable (disable) global struct reaggregation. This one can change the order of struct members, or split structs into multiple structs, to improve memory locality and cache utilization ๐requiredโ return an error condition if IPA gets inhibited for any reason, instead of the default behavior of just linking without IPA optimization.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. Trust issues fr fr ๐ญsafeall,nosafeall(default) โ declares that all unknown functions are safe (not safe); see-Mipa=safe.shape,noshape(default) โ perform (don't perform) Fortran 90 shape propagation.summaryโ only collect IPA summary information when compiling; this prevents IPA optimization of this file, but allows optimization for other files linked with this file. Team player energy ๐ซถvestigial,novestigial(default) โ remove (don't remove) functions that are not called. Bye to the npcs โ๏ธ
-Mlre[=assoc|noassoc],-Mnolreโ enable (disable) loop-carried redundancy elimination. Theassocoption allows expression reassociation, and thenoassocoption disallows expression reassociation.-Mmovnt,-Mnomovntโ force (disable) generation of nontemporal moves. Fun fact:-Mmovntused with-fastssecan sometimes be faster than-fastssealone. By default, nontemporal moves are generated for loops with large loop counts.-Mneginfo=option[,option...]โ tells the compiler to produce information on why certain optimizations are not performed. Um, use the-Minfoflag instead ๐-Mnoopenmpโ when-mpis present, ignore the OpenMP pragmas.-Mnosgimpโ when-mpis present, ignore the SGI parallelization pragmas.-Mnovintrโ do not generate vector intrinsic calls.-Mpfi[=option]โ generate profile feedback instrumentation; this includes extra code to collect run-time statistics to be used in a subsequent compile;-Mpfimust also appear when the program is linked. When the program is run, a profile feedback filepgfi.outwill be generated; see-Mpfo. The allowed options are:indirect,noindirect(default) โ enable (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 filepgfi.outin the current directory, which contains the result of an execution of the program compiled with-Mpfi. The options are:indirect,noindirect(default) โ enable (disable) indirect function call inlining; this requires apgfi.outfile generated from a binary built with-Mpfi=indirect.layout(default),nolayoutโ enable (disable) basic block layout to take advantage of instruction cache locality by keeping hot paths close together. Hot paths stay close, that's the whole vibe ๐ฅdir=directoryโ specify the directory containing thepgfi.outprofile feedback information file; the default is the current directory.
-Mpre,-Mnopre(default) โ enable (disable) the partial redundancy elimination optimization.-Mprefetch[=option:n],-Mnoprefetchโ add (don't add) prefetch instructions for those processors that support them (Pentium 4,Opteron);-Mprefetchis default onOpteron;-Mnoprefetchis 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 will cause the resulting executable to create a performance profile that can be viewed and analyzed with the PGPROF performance profiler. In the descriptions below, old-style profiling implies compiler-generated source instrumentation, and MPICH-style profiling implies the use of instrumented wrappers for MPI library routines. The-Mprofoptions 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 cap).linesโ perform old-style line level profiling.
timeโ makes a profile using time-based instruction-level statistical sampling. It's literally the same as-pg, except the profile gets saved to a file calledpgprof.outinstead ofgmon.out. ๐
On Linux systems with OProfile installed, PGPROF can collect performance data without recompiling. And for that mode of profiling, -Mprof=dwarf is the vibe. ๐ง
-Mpropcond(default) /-Mnopropcondโ turn on (or off) propagation of constant values that come from conditional branches with equality tests. โจ-Mquadโ align large objects on quad-word boundaries. bougie alignment behavior, no cap. ๐-Msafe_lastvalโ okay so sometimes a scalar gets used after a loop but isn't defined on every iteration of that loop, and by default the compiler is like "nope, not parallelizing that." This option tells the compiler "bestie it's safe, go parallelize it." ๐ซถ-Msafeptr[=option[,option,...]]/-Mnosafeptr(default) โ override (or don't override) data dependence between C pointers, and between pointers and variables or arrays.
โ ๏ธ Use this one with care โ there's real potential for the compiler to generate code that gives unexpected or incorrect results as defined by ANSI C. But when you use it properly, it can massively enhance performance, especially for floating-point oriented loops. You can combine the options and they'll interact appropriately. ๐ฅ
allโ all pointers are assumed not to overlap or conflict with other data objects.-Msafeptrwith no options implies-Msafeptr=all.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 are independent.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. ๐-Mstride0/-Mnostride0(default) โ generate (or don't generate) alternate code for a loop containing an induction variable whose increment may be zero. ๐-Munroll[=option[,option...]]/-Mnounroll(default) โ invoke (or don't invoke) the loop unroller. This also sets the optimization level to a minimum of2; see-O. The option is one of these:c:mโ tells the compiler to completely unroll loops with a constant loop count less than or equal to m, a supplied constant. If you don't supply this value, the m count is set to1. If m is set to1, a compiler heuristic determines the maximum loop count at which such loops will be completely unrolled.n:uโ tells the compiler to unroll u times, a single-block loop which is not completely unrolled, or has a non-constant loop count. If u isn't supplied, the unroller computes the number of times a candidate loop is unrolled.m:uโ tells the compiler to unroll u times, a multi-block loop which is not completely unrolled, or has a non-constant loop count. If u isn't supplied, the unroller computes the number of times a candidate loop is unrolled.
And -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 called unsafe for a reason: there are situations where the array elements allocated to some processors are not aligned. ๐-Mvect [=option[,option,...]]/-Mnovect(default) โ passes options to the internal vectorizer. This also sets the optimization level to a minimum of2, the equivalent of-Oโ for more info see optimization levels under-O. If you don't specify an option list, then these vector optimizations are used:assoc,cachesize:c,simd:256, where c is the actual cache size of the machine. The-Mvectoptions are:altcode(default) /noaltcodeโ enable (or disable) alternate code generation for vector loops, depending on characteristics like array alignments and loop counts.fuse/nofuse(default) โ enable (or disable) loop fusion, which combines adjacent loops into a single loop. ๐ฆprefetchโ use prefetch instructions in loops where it's profitable.simd[:{128|256|512}](default) /nosimdโ use vector SIMD instructions (AVX, AVX2, AVX512). The argument can limit usage to 128-bit SIMD instructions. Specifying 512-bit SIMD instructions is only possible for target processors that support AVX512. ๐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 options 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. ๐งฎcachesize:number(default=automatic) โ tells the vectorizer, when doing cache tiling optimizations, to assume a cache size of number.gather(default) /nogatherโ enable (or disable) vectorization of loops with indirect array references.idiom(default) /noidiomโ enable idiom recognition; an alternate form of-Midiom.levels:nโ set the maximum nest level of loops to optimize.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 get vectorized; the default is to attempt to vectorize all loops.tile/notile(default) โ enable (or disable) loop tiling to optimize for cache locality.
And -Mnovect disables the vectorizer โ it's the default at -O0 and -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. ๐
-mp[=option]โ enable OpenMP pragmas and directives to explicitly parallelize regions of code so they can run on accelerator devices or multiprocessor systems. The allowed options are:gpuโ compile OpenMP directives for parallel execution on the GPU. ๐ฎmulticore(default) โ compile OpenMP directives for parallel execution on the CPU.align/noalign(default) โ modify (or don't modify) default loop iteration scheduling so iterations align 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 don't link against OpenMP runtime libraries. โ๏ธ
๐ฅ OPTIONS: the -O levels (the main character energy section)
-O[level]โ sets the optimization level. If you don't specify-O, then the default level is1if-gisn't specified, and0if-gis specified. If you don't give a number with-O, the optimization level is set to2. Here's what each level means:-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. it's giving raw and unbothered. ๐-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. Plus, traditional scalar optimizations like induction recognition and loop invariant motion are performed by the global optimizer.-O2โ all-Ooptimizations are performed. Plus, more advanced optimizations like SIMD code generation, cache alignment and partial redundancy elimination are enabled. โจ-O3โ all-O1and-O2optimizations are performed. Plus, this level enables more aggressive code hoisting and scalar replacement optimizations that may or may not be profitable.-Ofastโ enables-O3,-Mfprelaxed,-Mstack_arrays,-Mno-nan,Mno-inf, and-fcx-limited-range. Note that-Mstack_arrayis disabled when both the command line options-Ofastand-stdparare enabled. ๐๏ธ
-O4โ all the-O1,-O2, and-O3optimizations are performed. On top of that, hoisting of guarded invariant floating-point expressions is enabled. ๐-pgโ enablegprof-style sample-based profiling; implies-Mframe. ๐
๐ Debugging Options ๐
okay bestie, this is the debugging section โ lowkey important, highkey iconic. ๐ ๏ธ
-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. Using-O0, the generated code will be slower than code generated at other optimization levels. ๐ญ-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. ๐ง-Mboundsโ add array bounds checking. ๐จ-Mnobounds(default) โ don't add array bounds checking. ๐ซ
Bounds checking is not applied to a subscripting pointer. ๐
-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. ๐-Mcoffโ generate a COFF formatted object. ๐ฆ-Mdwarf2โ generate DWARF2 debug information with-g. ๐งฌ-Mdwarf3โ generate DWARF3 debug information with-g. ๐งฌ-Melfโ generate an ELF formatted object. ๐ง-Mnodwarfโ don't add the default dwarf information. ๐-traceback,-notraceback(default) โ add debug information for runtime traceback. (-notracebackis the default.) ๐งต
โจ Preprocessor Options โจ
this is where the preprocessor does its little main-character thing. ๐
-Cโ preserve comments in preprocessed C source files. ๐ฌ-Dname[=def]โ definenameto bedefin the preprocessor. Ifdefis missing, it is assumed to be empty. If the=sign is missing, thennameis defined to be the string1. ๐ท๏ธ-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. ๐-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. ๐-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. ๐-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. ๐ท๏ธ-Eโ preprocess each.cfile and send the result to standard output. No compilation, assembly, or linking is performed. ๐-Idirectoryโ adddirectoryto 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. ๐งญ-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. ๐-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. ๐ฌ-Mโ generate a list of make dependences and print them to stdout.-MQand-MTare synonyms. ๐-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. ๐ท๏ธ
-MDโ generate a list of make dependences and print them to the filefile.d, wherefileis 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, wherefileis 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. ๐ซ-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. โ๏ธ-Pโ preprocess each file and leave the output in a file namedfile.ifor each file namedfile.c. ๐-Unameโ remove the definition of thenamemacro in the preprocessor. ๐๏ธ-YI,directoryโ change the standard include directory todirectory. ๐-Yp,directoryโ look indirectoryfor the preprocessor executable. ๐
โ๏ธ Assembler Options โ๏ธ
-Wa,option[,option...]โ pass each comma-delimited option to the assembler. ๐ ๏ธ-Ya,directoryโ look indirectoryfor the assembler executable. ๐
๐ Linker Options ๐
okay bestie, this is the link-line zone: every flag here gets passed along to the linker (or tells the driver what to put on the link line), and the facts stay exactly the same. no cap. ๐ซถ
-acclibsโ link-time option to add the accelerator libraries to the link line. โจ--as-needed,--no-as-neededโ passed to the linker. says 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โ same as-static; go check-staticfor the details.-Bstatic-nvidiaโ same as-static-nvidia; go check-static-nvidiafor the 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 are:cublascublasmpcufftcufftmpcufftwcurandcusolvercusolvermpcusparsecutensorncclnvblasnvshmemnvtx3
-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 ๐ธ
this is the language-flavor section, aka where you tell the compiler what counts as C, what counts as assembly, and which little language-lawyer rules are in effect. periodt. ๐
-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โ 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โ enable loop autoparallelization within parallel constructs;noautoparturns it off. ๐ฅgpu(default) โ compile OpenACC directives for parallel execution on the GPU. ๐hostโ compile OpenACC directives for serial execution on the host CPU.legacyโ suppress warnings about deprecated PGI accelerator directives.multicoreโ compile OpenACC directives 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โ issue warnings when accelerator directives are encountered which do not adhere to the OpenACC standard.syncโ ignoreasyncclauses, and run every data transfer and kernel launch on the default sync queue.verystrictโ abort compilation with a fatal error when an accelerator directive is encountered which does not adhere to the OpenACC standard. Like, full stop, no vibes. ๐wait(default),nowaitโ wait for each compute kernel to finish;nowaitsays donโt. ๐ซถ-noaccโ disable OpenACC directives and do not link with OpenACC libraries.-gpu=optionโ use the following sub-options to tailor the compilation of target accelerator regions:autocompareโ automatically compare CPU/GPU results. Accelerated code sections will be run in redundant mode, and data will be 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 will be generated for each. By default, the compiler will detect 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.ccnativeโ detects the visible GPUs on the system and generates codes for them. If no device is available the default compute capability will be used (cc50).ccall-majorโ compile for all major supported compute capabilities (does not include PTX for the highest major virtual architecture, see-gpu=[no]rdcoption 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.flushz,noflushz(default) โ enable (disable) flush-to-zero mode on the GPU.fma,nofmaโ generate (do not) fused multiply-add operations on the GPU. This is enabled by default at optimization level-O1.implicitsections,noimplicitsections(default) โ change (do not change) array element references in OpenACC and OpenMP data clause to array sections references.interceptdeallocations,nointerceptdeallocationsโ intercept (do not intercept) LIBC function calls (e.g.free) and call the corresponding CUDA memory deallocation version if address is in pinned or managed memory, 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=ltois 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 the L1 or L2 hardware 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 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 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โ print ptxas information.rdc(default),nordcโ generate (do not 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 CPU. Implied byautocompare.safecacheโ allow variable-sized array sections in cache directives; compiler assumes they fit into CUDA shared memory.sm_XYโ generate code for a device with compute capability XY. Multiple compute capabilities can be specified, and one version will be generated for each. By default, the compiler will detect 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 exceedslimitKBytes. 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 (do not 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. 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 the 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++mainfunction 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-ftzis the default 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 with g77, which adds a second underscore to such symbols by default.-Mwritable-stringsโ store string constants in the writable data segment.-mcmodel=small|mediumโ pick the memory model vibe:smallโ 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 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 nvc(1) page, bestie โ catch you in the September 2026 edition of nvc(1) ๐โจ
๐ฆ 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