Skip to content

Commit

Permalink
Add extra info to assertions in cux.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuric committed May 20, 2010
1 parent 524c421 commit 6d1cb6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
26 changes: 13 additions & 13 deletions galaxy.kdevelop
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<secondaryLanguages/>
<versioncontrol/>
<projectname>galaxy</projectname>
<defaultencoding/>
<defaultencoding></defaultencoding>
</general>
<kdevautoproject>
<general>
<activetarget>src/galfast.x</activetarget>
<useconfiguration>debug</useconfiguration>
<useconfiguration>optimized</useconfiguration>
</general>
<run>
<mainprogram>/home/mjuric/projects/galaxy/debug/src/galfast.x</mainprogram>
Expand Down Expand Up @@ -81,14 +81,14 @@
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O2 -Wstrict-aliasing -fno-strict-aliasing</cxxflags>
<configargs>--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</configargs>
<topsourcedir/>
<topsourcedir></topsourcedir>
<cppflags>-DDEBUGMODE=0</cppflags>
<ldflags>-rdynamic -L/opt/cudatools/2.3/lib</ldflags>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<f77flags/>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<cflags></cflags>
<f77flags></f77flags>
<envvars/>
</optimized>
<debug>
Expand Down Expand Up @@ -206,7 +206,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
Expand All @@ -232,11 +232,11 @@
<kdevdebugger>
<general>
<programargs>postprocess postprocess.conf skygen.conf</programargs>
<gdbpath/>
<gdbpath></gdbpath>
<dbgshell>libtool --mode=execute</dbgshell>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
Expand Down
32 changes: 17 additions & 15 deletions src/common/cux.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
#ifndef cuda_cux__
#define cuda_cux__

#include <assert.h>
#include <cassert>
#include <cstdio>
#include <map>
#include <set>
#include <algorithm>

#include <astro/assert.h>

#include "cux_lowlevel.h"

/**
Expand Down Expand Up @@ -143,7 +146,7 @@ template<typename T>
#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
}
Expand Down Expand Up @@ -243,7 +246,7 @@ template<typename T, int dim = 1, int align = 128>
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);
Expand All @@ -255,7 +258,7 @@ template<typename T, int dim = 1, int align = 128>
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);
Expand All @@ -269,7 +272,7 @@ template<typename T, int dim = 1, int align = 128>
}
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; }
Expand Down Expand Up @@ -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<T, 3> *)(&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<T, 2> *)(&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<T, 1> *)(&m_impl->m_data))(x);
}
Expand Down Expand Up @@ -667,15 +671,15 @@ struct cuxTexture : public cuxSmartPtr<T>
}
void set(const cuxSmartPtr<T>& a, const float2 tcx, const float2 tcy)
{
assert(dim == 2);
ASSERT(dim == 2) { fprintf(stderr, "dim=%d\n", dim); }

*this = a;
coords[0] = tcx;
coords[1] = tcy;
}
void set(const cuxSmartPtr<T>& 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;
Expand Down Expand Up @@ -729,8 +733,6 @@ template<typename T, int dim, enum cudaTextureReadMode mode>
struct cuxTextureReference : public cuxTextureReferenceInterface
{
public:
/* cuxSmartPtr<T> data;
cuxTexCoords<dim> tc;*/
cuxTexture<T, dim> 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
Expand Down

0 comments on commit 6d1cb6f

Please sign in to comment.