Loading...
Searching...
No Matches
Valgrind.hpp File Reference

Some templates to wrap the valgrind client request macros. More...

`#include <opm/common/utility/gpuDecorators.hpp>`

Go to the source code of this file.

## Namespaces

namespace | Opm
| This class implements a small container which holds the transmissibility mulitpliers for all the faces in the grid.

## Functions

OPM_HOST_DEVICE bool | Opm::Valgrind::IsRunning ()
| Returns whether the program is running under Valgrind or not.
template<class T>
OPM_HOST_DEVICE bool | Opm::Valgrind::CheckDefined (const T &value)
| Make valgrind complain if any of the memory occupied by an object is undefined.
template<class T>
OPM_HOST_DEVICE bool | Opm::Valgrind::CheckAddressable (const T &value)
| Make valgrind complain if any of the memory occupied by an object is not addressable.
template<class T>
OPM_HOST_DEVICE bool | Opm::Valgrind::CheckDefined (const T *value, int size)
| Make valgrind complain if any of the the memory occupied by a C-style array objects is undefined.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetUndefined (const T &value)
| Make the memory on which an object resides undefined in valgrind runs.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetUndefined (const T *value, int size)
| Make the memory on which an array of object resides undefined in valgrind runs.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetDefined (const T &value)
| Make the memory on which an object resides defined.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetDefined (const T *value, int n)
| Make the memory on which a C-style array of objects resides defined.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetNoAccess (const T &value)
| Make valgrind complain if an object's memory is accessed.
template<class T>
OPM_HOST_DEVICE void | Opm::Valgrind::SetNoAccess (const T *value, int size)
| Make valgrind complain if the memory of a C-style array of objects is accessed.

## Detailed Description

Some templates to wrap the valgrind client request macros.

## Function Documentation

## CheckAddressable()

template<class T>

OPM_HOST_DEVICE bool Opm::Valgrind::CheckAddressable | ( | const T & | value | ) |

inline

Make valgrind complain if any of the memory occupied by an object is not addressable.

Example:

int* i = nullptr;
Valgrind::CheckAddressable(*i); // Valgrind complains!

Template Parameters

  T | The type of the object which ought to be checked

Parameters

  value | the object which valgrind should check

Returns
  true iff there are no unadressable bytes in the memory occupied by the object.

## CheckDefined() [1/2]

template<class T>

OPM_HOST_DEVICE bool Opm::Valgrind::CheckDefined | ( | const T & | value | ) |

inline

Make valgrind complain if any of the memory occupied by an object is undefined.

Please note that this does not check whether the destinations of an object's pointers or references are defined. Also, for performance reasons the compiler might insert "padding bytes" between within the objects which leads to false positives.

Example:

int i;
Valgrind::CheckDefined(i); // Valgrind complains!

Template Parameters

  T | The type of the object which ought to be checked

Parameters

  value | the object which valgrind should check

Returns
  true iff there are no undefined bytes in the memory occupied by the object.

## CheckDefined() [2/2]

template<class T>

OPM_HOST_DEVICE bool Opm::Valgrind::CheckDefined | ( | const T * | value,
|  | int | size )

inline

Make valgrind complain if any of the the memory occupied by a C-style array objects is undefined.

Please note that this does not check whether the destinations of an object's pointers or references are defined. Also, for performance reasons the compiler might insert "padding bytes" between within the objects which leads to false positives.

Example:

int i[2];
Valgrind::CheckDefined(i, 2); // Valgrind complains!

Template Parameters

  T | The type of the object which ought to be checked

Parameters

  value | Pointer to the first object of the array.
  size | The size of the array in number of objects

Returns
  true iff there are no undefined bytes in the memory occupied by the array.

## SetDefined() [1/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetDefined | ( | const T & | value | ) |

inline

Make the memory on which an object resides defined.

Example:

int i;
Valgrind::SetDefined(i);
Valgrind::CheckDefined(i); // Valgrind does not complain!

Template Parameters

  T | The type of the object which valgrind should consider as defined

Parameters

  value | The object which's memory valgrind should consider as defined

## SetDefined() [2/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetDefined | ( | const T * | value,
|  | int | n )

inline

Make the memory on which a C-style array of objects resides defined.

Example:

int i[3];
Valgrind::SetDefined(i, 3);
Valgrind::CheckDefined(i, 3); // Valgrind does not complain!

Template Parameters

  T | The type of the object which valgrind should consider as defined

Parameters

  value | Pointer to the first object of the array.
  n | The size of the array in number of objects

## SetNoAccess() [1/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetNoAccess | ( | const T & | value | ) |

inline

Make valgrind complain if an object's memory is accessed.

Example:

int i = 1;
Valgrind::SetNoAccess(i);
int j = i; // Valgrind complains!

Template Parameters

  T | The type of the object which valgrind should complain if accessed

Parameters

  value | The object which's memory valgrind should complain if accessed

## SetNoAccess() [2/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetNoAccess | ( | const T * | value,
|  | int | size )

inline

Make valgrind complain if the memory of a C-style array of objects is accessed.

Example:

int i[3] = {0, 1, 2};
Valgrind::SetNoAccess(i, 2);
int j = i[1]; // Valgrind complains!

Parameters

  value | Pointer to the first object of the array.
  size | The size of the array in number of objects

## SetUndefined() [1/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetUndefined | ( | const T & | value | ) |

inline

Make the memory on which an object resides undefined in valgrind runs.

Example:

int i = 0;
Valgrind::SetUndefined(i);
Valgrind::CheckDefined(i); // Valgrind complains!

Template Parameters

  T | The type of the object which ought to be set to undefined

Parameters

  value | The object which's memory valgrind should be told is undefined

## SetUndefined() [2/2]

template<class T>

OPM_HOST_DEVICE void Opm::Valgrind::SetUndefined | ( | const T * | value,
|  | int | size )

inline

Make the memory on which an array of object resides undefined in valgrind runs.

Example:

int i[3] = {0, 1, 3};
Valgrind::SetUndefined(&i[1], 2);
Valgrind::CheckDefined(i, 3); // Valgrind complains!

Template Parameters

  T | The type of the object which ought to be set to undefined

Parameters

  value | Pointer to the first object of the array.
  size | The size of the array in number of objects