Open Catalog of Code Guidelines for Correctness, Modernization, Security, Portability, and Optimization
About
This Open Catalog is a collaborative effort to consolidate expert knowledge on code guidelines for the correctness, modernization, security, portability, 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, modernization, security, and portability recommendations.
- Potential performance enhancements achievable through the optimization recommendations.
Checks
| ID | Title | Category | CWE | ISO/IEC 24772-8 | SEI CERT C | SEI CERT C++ | C | Fortran | C++ | AutoFix |
|---|---|---|---|---|---|---|---|---|---|---|
| PWR001 | Pass global variables as function arguments | correctness, modernization, security | CWE-1108 | DCL19-C | ✓ | ✓ | ✓ | |||
| PWR002 | Declare scalar variables in the smallest possible scope | correctness, modernization, security | CWE-1126 | DCL19-C | ✓ | ✓ | ||||
| PWR003 | Explicitly declare pure functions | modernization, security | 6.24, 6.32 | ✓ | ✓ | ✓ | ||||
| PWR004 | Declare OpenMP scoping for all variables | correctness, security | ✓ | ✓ | ✓ | |||||
| PWR005 | Disable default OpenMP scoping | correctness, security | ✓ | ✓ | ✓ | |||||
| PWR006 | Avoid privatization of read-only variables | optimization | ✓ | ✓ | ✓ | |||||
| PWR007 | Disable the implicit declaration of variables and procedures | correctness, modernization, security | CWE-628 | 6.17, 6.18, 6.19, 6.21, 6.54, 7.2 | DCL07-C, DCL31-C, EXP37-C | ✓ | ✓1 | |||
| PWR008 | Declare the intent for each procedure argument | correctness, modernization, security | CWE-374 | 6.32, 6.65 | DCL13-C | ✓ | ✓1 | |||
| PWR009 | Use OpenMP teams to offload work to GPU | optimization | ✓ | ✓ | ✓ | |||||
| PWR012 | Pass only required fields from derived type as arguments | modernization, optimization | ✓ | ✓ | ✓ | |||||
| PWR013 | Avoid copying unused variables to or from the GPU | optimization | ✓ | ✓ | ✓ | |||||
| PWR014 | Out-of-dimension-bounds matrix access | correctness, security | CWE-125, CWE-787 | 6.8, 6.9, 6.10 | ARR30-C | ✓ | ✓ | |||
| PWR015 | Avoid copying unnecessary array elements to or from the GPU | optimization | ✓ | ✓ | ✓ | |||||
| PWR016 | Use separate arrays instead of an Array-of-Structs | security, optimization | CWE-1043 | ✓ | ✓ | ✓ | ||||
| PWR017 | Using countable while loops instead of for loops may inhibit vectorization | security, optimization | CWE-1095 | ✓ | ✓ | |||||
| PWR018 | Call to recursive function within a loop inhibits vectorization | security, optimization | CWE-674 | 6.35, 6.43 | ✓ | ✓ | ✓ | |||
| PWR019 | Consider interchanging loops to favor vectorization by maximizing inner loop's trip count | optimization | ✓ | ✓ | ✓ | |||||
| PWR020 | Consider loop fission to enable vectorization | optimization | ✓ | ✓ | ✓ | |||||
| PWR021 | Consider loop fission with scalar to vector promotion to enable vectorization | optimization | ✓ | ✓ | ✓ | |||||
| PWR022 | Move invariant conditional out of the loop to facilitate vectorization | optimization | ✓ | ✓ | ✓ | |||||
| PWR023 | Add 'restrict' for pointer function arguments to hint the compiler that vectorization is safe | optimization | ✓ | ✓ | ||||||
| PWR024 | Loop can be rewritten in OpenMP canonical form | optimization | ✓ | ✓ | ||||||
| PWR025 | Consider annotating pure function with OpenMP 'declare simd' | optimization | ✓ | ✓ | ✓ | |||||
| PWR026 | Annotate function for OpenMP Offload | optimization | ✓ | ✓ | ✓ | |||||
| PWR027 | Annotate function for OpenACC Offload | optimization | ✓ | ✓ | ✓ | |||||
| PWR028 | Remove pointer increment preventing performance optimization | security, optimization | CWE-468 | EXP08-C | ✓ | ✓ | ||||
| PWR029 | Remove integer increment preventing performance optimization | optimization | ✓ | ✓ | ✓ | |||||
| PWR030 | Remove pointer assignment preventing performance optimization for perfectly nested loops | security, optimization | CWE-468 | EXP08-C | ✓ | ✓ | ✓ | |||
| PWR031 | Replace pow by multiplication, division and/or square root | optimization | ✓ | ✓ | ✓ | |||||
| PWR032 | Avoid calls to mathematical functions with higher precision than required | optimization | ✓ | ✓ | ||||||
| PWR034 | Avoid strided array access to improve performance | optimization | ✓ | ✓ | ✓ | |||||
| PWR035 | Avoid non-consecutive array access to improve performance | optimization | ✓ | ✓ | ✓ | |||||
| PWR036 | Avoid indirect array access to improve performance | optimization | ✓ | ✓ | ✓ | |||||
| PWR037 | Potential precision loss in call to mathematical function | correctness, security | CWE-197 | 6.2, 6.6 | FLP34-C | ✓ |