Skip to main content

Open Catalog of Code Guidelines for Correctness, Modernization, and Optimization

About

This Open Catalog is a collaborative effort to consolidate expert knowledge on code guidelines for the correctness, modernization, and optimization of code written in C, C++, and Fortran programming languages. The Catalog consists of a comprehensive set of checks (rules) that describe specific issues in the source code and provide guidance on corrective actions, along with extensive documentation, example codes and references to additional reading resources.

Benchmarks

The Open Catalog includes a suite of microbenchmarks designed to demonstrate:

  • No performance degradation when implementing the correctness and modernization recommendations.
  • Potential performance enhancements achievable through the optimization recommendations.

Checks

IDTitleCategoryCFortranC++AutoFix
PWR001Declare global variables as function parameterscorrectness
PWR002Declare scalar variables in the smallest possible scopecorrectness
PWR003Explicitly declare pure functionsmodernization
PWR004Declare OpenMP scoping for all variablescorrectness
PWR005Disable default OpenMP scopingcorrectness
PWR006Avoid privatization of read-only variablesoptimization
PWR007Disable implicit declaration of variablescorrectness1
PWR008Declare the intent for each procedure parametercorrectness1
PWR009Use OpenMP teams to offload work to GPUoptimization
PWR010Avoid column-major array access in C/C++optimization
PWR012Pass only required fields from derived type as parametersoptimization
PWR013Avoid copying unused variables to or from the GPUoptimization
PWR014Out-of-dimension-bounds matrix accesscorrectness
PWR015Avoid copying unnecessary array elements to or from the GPUoptimization
PWR016Use separate arrays instead of an Array-of-Structsoptimization
PWR017Using countable while loops instead of for loops may inhibit vectorizationoptimization
PWR018Call to recursive function within a loop inhibits vectorizationoptimization
PWR019Consider interchanging loops to favor vectorization by maximizing inner loop's trip countoptimization
PWR020Consider loop fission to enable vectorizationoptimization
PWR021Consider loop fission with scalar to vector promotion to enable vectorizationoptimization
PWR022Move invariant conditional out of the loop to facilitate vectorizationoptimization
PWR023Add 'restrict' for pointer function parameters to hint the compiler that vectorization is safeoptimization
PWR024Loop can be rewritten in OpenMP canonical formoptimization
PWR025Consider annotating pure function with OpenMP 'declare simd'optimization
PWR026Annotate function for OpenMP Offloadoptimization
PWR027Annotate function for OpenACC Offloadoptimization
PWR028Remove pointer increment preventing performance optimizationoptimization
PWR029Remove integer increment preventing performance optimizationoptimization
PWR030Remove pointer assignment preventing performance optimization for perfectly nested loopsoptimization
PWR031Replace pow by multiplication, division and/or square rootoptimization
PWR032Avoid calls to mathematical functions with higher precision than requiredoptimization
PWR033Move invariant conditional out of the loop to avoid redundant computationsoptimization
PWR034Avoid strided array access to improve performanceoptimization
PWR035Avoid non-consecutive array access to improve performanceoptimization
PWR036Avoid indirect array access to improve performanceoptimization
PWR037Potential precision loss in call to mathematical functioncorrectness
PWR039Consider loop interchange to improve the locality of reference and enable vectorizationoptimization1
PWR040Consider loop tiling to improve the locality of referenceoptimization
PWR042Consider loop interchange by promoting the scalar reduction variable to an arrayoptimization
PWR043Consider loop interchange by replacing the scalar reduction valueoptimization
PWR044Avoid unnecessary floating-point data conversions involving constantsoptimization
PWR045Replace division with a multiplication with a reciprocaloptimization
PWR046Replace two divisions with a division and a multiplicationoptimization
PWR048Replace multiplication/addition combo with an explicit call to fused multiply-addoptimization
PWR049Move iterator-dependent condition outside of the loopoptimization
PWR050Consider applying multithreading parallelism to forall loopoptimization1
PWR051Consider applying multithreading parallelism to scalar reduction loopoptimization1
PWR052Consider applying multithreading parallelism to sparse reduction loopoptimization1
PWR053Consider applying vectorization to forall loopoptimization1
PWR054Consider applying vectorization to scalar reduction loopoptimization1
PWR055Consider applying offloading parallelism to forall loopoptimization1
PWR056Consider applying offloading parallelism to scalar reduction loopoptimization1
PWR057Consider applying offloading parallelism to sparse reduction loopoptimization1
PWR060Consider loop fission to separate gather memory access patternoptimization
PWR062Consider loop interchange by removing accumulation on array valueoptimization
PWR063Avoid using legacy Fortran constructsmodernization
PWR068Encapsulate procedures within modules to avoid the risks of calling implicit interfacescorrectness
PWR069Use the keyword only to explicitly state what to import from a modulecorrectness1
PWR070Declare array dummy arguments as assumed-shape arrayscorrectness
PWR071Prefer real(kind=kind_value) for declaring consistent floating typesmodernization
PWR072Split the variable initialization from the declaration to prevent the implicit 'save' behaviorcorrectness1
PWR073Transform common block into a module for better data encapsulationmodernization
PWR075Avoid using GNU Fortran extensionsmodernization
PWR079Avoid undefined behavior due to uninitialized variablescorrectness
PWD002Unprotected multithreading reduction operationcorrectness
PWD003Missing array range in data copy to the GPUcorrectness
PWD004Out-of-memory-bounds array accesscorrectness
PWD005Array range copied to or from the GPU does not cover the used rangecorrectness
PWD006Missing deep copy of non-contiguous data to the GPUcorrectness
PWD007Unprotected multithreading recurrencecorrectness
PWD008Unprotected multithreading recurrence due to out-of-dimension-bounds array accesscorrectness
PWD009Incorrect privatization in parallel regioncorrectness
PWD010Incorrect sharing in parallel regioncorrectness
PWD011Missing OpenMP lastprivate clausecorrectness
RMK001Loop nesting that might benefit from hybrid parallelization using multithreading and SIMDoptimization
RMK002Loop nesting that might benefit from hybrid parallelization using offloading and SIMDoptimization
RMK003Potentially privatizable temporary variableoptimization
RMK007Vectorization opportunity within a multithreaded regionoptimization
RMK008Vectorization opportunity within an offloaded regionoptimization
RMK009Outline loop to increase compiler and tooling code coverageoptimization
RMK010Strided memory accesses in the loop body may prevent vectorizationoptimization
RMK012Conditional execution in the loop body may prevent vectorizationoptimization
RMK013Low trip count unknown at compile time may prevent vectorization of the loopoptimization
RMK014Unpredictable memory accesses in the loop body may prevent vectorizationoptimization
RMK015Tune compiler optimization flags to increase the speed of the codeoptimization
RMK016Tune compiler optimization flags to avoid potential changes in floating point precisioncorrectness

AutoFix: Denotes tools that support automatic correction of the corresponding check. Readers are encouraged to report additional tools with autofix capabilities for these checks. The tools are tagged in the table as follows:

Contributing

We welcome and encourage contributions to the Open Catalog! Here's how you can get involved:

  1. Join the discussion:

    Got ideas, questions, or suggestions? Head over to our GitHub Discussions. It's the perfect place for open-ended conversations and brainstorming!

  2. Report issues:

    Found inaccuracies, unclear explanations, or other problems? Please open an Issue. Detailed reports help us quickly improve the quality of the project!

  3. Submit pull requests:

    Interested in solving any issues? Feel free to fork the repository, make your changes, and submit a Pull Request. We'd love to see your contributions!

Footnotes

  1. Codee 2 3 4 5 6 7 8 9 10 11 12 13