PETSC_ATTRIBUTE_COLD#

Indicate to the compiler that a function is very unlikely to be executed

Notes#

The marked function is often optimized for size rather than speed and may be grouped alongside other equally frigid routines improving code locality of lukewarm or hotter parts of program.

The paths leading to cold functions are usually automatically marked as unlikely by the compiler. It may thus be useful to mark functions used to handle unlikely conditions – such as error handlers – as cold to improve optimization of the surrounding temperate functions.

Example Usage#

  void my_error_handler(...) PETSC_ATTRIBUTE_COLD;

  if (temperature < 0) {
    return my_error_handler(...); // chilly!
  }

See Also#

PetscUnlikely(), PetscUnlikelyDebug(), PetscLikely(), PetscLikelyDebug(), PetscUnreachable(), PETSC_ATTRIBUTE_FORMAT

Level#

intermediate

Location#

include/petscmacros.h


Edit on GitLab

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages