imate
C++/CUDA Reference
debugging.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3  * SPDX-License-Identifier: BSD-3-Clause
4  * SPDX-FileType: SOURCE
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the license found in the LICENSE.txt file in the root
8  * directory of this source tree.
9  */
10 
11 
12 #ifndef _DEFINITIONS_DEBUGGING_H_
13 #define _DEFINITIONS_DEBUGGING_H_
14 
15 #include <iostream>
16 
17 // To avoid "controlling expression is constant" warning by nvcc compiler when
18 // there are messages in the assert function, use this instead of assert.
19 
20 #define ASSERT(condition, message) \
21  do { \
22  if (!(condition)) { \
23  std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
24  << " line " << __LINE__ << ": " << message << std::endl; \
25  std::terminate(); \
26  } \
27  } while (false)
28 
29 
30 #endif // _DEFINITIONS_DEBUGGING_H_