From 6d1cb6fe3a9a09ca3ebef1ee72a1f89974ca876a Mon Sep 17 00:00:00 2001 From: Mario Juric Date: Thu, 20 May 2010 02:52:42 -0400 Subject: [PATCH] Add extra info to assertions in cux.h --- galaxy.kdevelop | 26 +++++++++++++------------- src/common/cux.h | 32 +++++++++++++++++--------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/galaxy.kdevelop b/galaxy.kdevelop index 922ebd1..505587a 100644 --- a/galaxy.kdevelop +++ b/galaxy.kdevelop @@ -17,12 +17,12 @@ galaxy - + src/galfast.x - debug + optimized /home/mjuric/projects/galaxy/debug/src/galfast.x @@ -81,14 +81,14 @@ kdevg77options -O2 -Wstrict-aliasing -fno-strict-aliasing --with-cuda --enable-cuda-devemuX --with-sm=/usr/local --with-libpeyton=$HOME/projects/libpeyton --prefix=$HOME/projects/galaxy/workspace/staging --with-cfitsio-include=/usr/include/cfitsio --with-libpeyton-libdir=$HOME/projects/libpeyton/lib-optimized - + -DDEBUGMODE=0 -rdynamic -L/opt/cudatools/2.3/lib - - - - - + + + + + @@ -206,7 +206,7 @@ - + set m_,_ theValue @@ -232,11 +232,11 @@ postprocess postprocess.conf skygen.conf - + libtool --mode=execute - - - + + + true false false diff --git a/src/common/cux.h b/src/common/cux.h index 3dfcde2..c9dd33f 100644 --- a/src/common/cux.h +++ b/src/common/cux.h @@ -21,11 +21,14 @@ #ifndef cuda_cux__ #define cuda_cux__ -#include +#include +#include #include #include #include +#include + #include "cux_lowlevel.h" /** @@ -143,7 +146,7 @@ template #elif BUILD_FOR_CPU memcpy(&dest, &source, size); #else - assert(0); + ASSERT(0); //#error cuxUploadConst can be used only in .cu files, or when BUILD_FOR_CPU is defined #endif } @@ -243,7 +246,7 @@ template if(!this->ptr) { if(dim == 1) { alloc(lastdim); } // auto-allocation allowed only for 1D arrays (convenience) - else { assert(this->ptr); } + else { ASSERT(this->ptr); } } size_t size = memsize(lastdim); @@ -255,7 +258,7 @@ template if(!this->ptr) { if(dim == 1) { alloc(lastdim); } // auto-allocation allowed only for 1D arrays (convenience) - else { assert(this->ptr); } + else { ASSERT(this->ptr); } } size_t size = memsize(lastdim); @@ -269,7 +272,7 @@ template } void alloc(size_t nx, size_t ny = 1, size_t nz = 1) { - assert(dim <= 4); // not implemented for dim > 4 + ASSERT(dim <= 4); // not implemented for dim > 4 if(dim > 1) { this->extent[0] = roundUpModulo(nx*sizeof(T), align); } if(dim > 2) { this->extent[1] = ny; } @@ -512,22 +515,23 @@ struct cuxSmartPtr // host data accessors (note: use hptr<> interface if maximum speed is needed) T& operator()(const uint32_t x, const uint32_t y, const uint32_t z) const // 3D accessor (valid only if dim = 3) { - assert(x < width()); - assert(y < height()); - assert(z < depth()); + ASSERT(x < width()) { fprintf(stderr, "x=%u, width()=%u\n", x, width()); } + ASSERT(y < height()) { fprintf(stderr, "y=%u, height()=%u\n", y, height()); } + ASSERT(z < depth()) { fprintf(stderr, "z=%u, depth()=%u\n", z, depth()); } if(m_impl->onDevice || !m_impl->m_data.ptr) { syncToHost(); } return (*(arrayPtr *)(&m_impl->m_data))(x, y, z); } T& operator()(const uint32_t x, const uint32_t y) const // 2D accessor (valid only if dim >= 2) { - assert(x < width()); - assert(y < height()); + ASSERT(x < width()) { fprintf(stderr, "x=%u, width()=%u\n", x, width()); } + ASSERT(y < height()) { fprintf(stderr, "y=%u, height()=%u\n", y, height()); } if(m_impl->onDevice || !m_impl->m_data.ptr) { syncToHost(); } return (*(arrayPtr *)(&m_impl->m_data))(x, y); } T& operator()(const uint32_t x) const // 1D accessor (valid only if dim >= 2) { - assert(x < width()); + ASSERT(x < width()) { fprintf(stderr, "x=%u, width()=%u\n", x, width()); } + if(m_impl->onDevice || !m_impl->m_data.ptr) { syncToHost(); } return (*(arrayPtr *)(&m_impl->m_data))(x); } @@ -667,7 +671,7 @@ struct cuxTexture : public cuxSmartPtr } void set(const cuxSmartPtr& a, const float2 tcx, const float2 tcy) { - assert(dim == 2); + ASSERT(dim == 2) { fprintf(stderr, "dim=%d\n", dim); } *this = a; coords[0] = tcx; @@ -675,7 +679,7 @@ struct cuxTexture : public cuxSmartPtr } void set(const cuxSmartPtr& a, const float2 tcx, const float2 tcy, const float2 tcz) { - assert(dim == 3); + ASSERT(dim == 3) { fprintf(stderr, "dim=%d\n", dim); } *this = a; coords[0] = tcx; @@ -729,8 +733,6 @@ template struct cuxTextureReference : public cuxTextureReferenceInterface { public: -/* cuxSmartPtr data; - cuxTexCoords tc;*/ cuxTexture tex; // the texture from which we're going to sample textureReference &texref; // the CUDA texture reference to which the current texture will be bound const char *tcSymbolName; // the symbol name of the __constant__ variable that holds the texture