Swarm-NG  1.1
gpulog_debug.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Mario Juric *
3  * mjuric@cfa.harvard.EDU *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
27 #ifndef bits_gpulog_debug_h__
28 #define bits_gpulog_debug_h__
29 
33 #if GPULOG_DEBUG
34  #define DBG(x) x
35 #else
36  #define DBG(x)
37 #endif
38 
39 #if !__CUDACC__
40  #include <iostream>
41  #include <cassert>
42  #include <sstream>
43 
44  #define DHOST(x) DBG(x)
45  #define DGPU(x)
46 
47  #define dev_assert(x) assert(x)
48 #else
49  #define DHOST(x) /* This hides the stuff that nvcc can't compile */
50 
51  #if __DEVICE_EMULATION__
52  #define DGPU(x) DBG(x)
53  // #define dev_assert(x) assert(x) /* has to be disabled on CUDA 2.3 or compilation fails */
54  #define dev_assert(x) { if(!(x)) { printf("Assertion failed: " #x "\n"); exit(-1); } } /* This is a CUDA 2.3 compatible replacement for assert(); */
55  // #define dev_assert(x)
56  #else
57  #define DGPU(x)
58  #define dev_assert(x)
59  #endif
60 #endif
61 
62 #endif // bits_gpulog_debug_h