gpulog_debug.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2010 by Mario Juric                                     *
00003  *   mjuric@cfa.harvard.EDU                                                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00027 #ifndef bits_gpulog_debug_h__
00028 #define bits_gpulog_debug_h__
00029 
00033 #if GPULOG_DEBUG
00034         #define DBG(x) x
00035 #else
00036         #define DBG(x)
00037 #endif
00038 
00039 #if !__CUDACC__
00040         #include <iostream>
00041         #include <cassert>
00042         #include <sstream>
00043 
00044         #define DHOST(x) DBG(x)
00045         #define DGPU(x)
00046         
00047         #define dev_assert(x) assert(x)
00048 #else
00049         #define DHOST(x)        /* This hides the stuff that nvcc can't compile */
00050 
00051         #if __DEVICE_EMULATION__
00052                 #define DGPU(x) DBG(x)
00053                 // #define dev_assert(x) assert(x) /* has to be disabled on CUDA 2.3 or compilation fails */
00054                 #define dev_assert(x) { if(!(x)) { printf("Assertion failed: " #x "\n"); exit(-1); } } /* This is a CUDA 2.3 compatible replacement for assert(); */
00055                 // #define dev_assert(x)
00056         #else
00057                 #define DGPU(x)
00058                 #define dev_assert(x)
00059         #endif
00060 #endif
00061 
00062 #endif // bits_gpulog_debug_h

doxygen