Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/popsift/common/plane_2d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ __host__
void PlaneBase::memcpyToHost( void* dst, int dst_pitch,
void* src, int src_pitch,
short cols, short rows,
int elemSize )
int elemSize ) const
{
assert( dst != 0 );
assert( dst_pitch != 0 );
Expand All @@ -185,7 +185,7 @@ void PlaneBase::memcpyToHost( void* dst, int dst_pitch,
void* src, int src_pitch,
short cols, short rows,
int elemSize,
cudaStream_t stream )
cudaStream_t stream ) const
{
assert( dst != 0 );
assert( dst_pitch != 0 );
Expand Down
55 changes: 28 additions & 27 deletions src/popsift/common/plane_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ struct PlaneBase
void memcpyToDevice( void* dst, int dst_pitch, void* src, int src_pitch, short cols, short rows, int elemSize, cudaStream_t stream );

__host__
void memcpyToHost( void* dst, int dst_pitch, void* src, int src_pitch, short cols, short rows, int elemSize );
void memcpyToHost( void* dst, int dst_pitch, void* src, int src_pitch, short cols, short rows, int elemSize ) const;

__host__
void memcpyToHost( void* dst, int dst_pitch, void* src, int src_pitch, short cols, short rows, int elemSize, cudaStream_t stream );
void memcpyToHost( void* dst, int dst_pitch, void* src, int src_pitch, short cols, short rows, int elemSize, cudaStream_t stream ) const;

#ifdef PLANE2D_CUDA_OP_DEBUG
__host__
Expand Down Expand Up @@ -130,17 +130,18 @@ template <typename T> struct PitchPlane2D : public PlaneT<T>

/** cuda memcpy from parameter (plane allocated on device) to
* this (plane allocated on host) */
__host__ inline void memcpyFromDevice( PitchPlane2D<T>& devPlane,
__host__ inline void memcpyFromDevice( const PitchPlane2D<T>& devPlane,
short cols, short rows );
__host__ inline void memcpyFromDevice( PitchPlane2D<T>& devPlane,
short cols, short rows, cudaStream_t stream );
__host__ inline void memcpyFromDevice( const PitchPlane2D<T>& devPlane,
short cols, short rows,
cudaStream_t stream );

/** cuda memcpy from this (plane allocated on device) to
* parameter (plane allocated on host) */
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane,
short cols, short rows );
short cols, short rows ) const;
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane,
short cols, short rows, cudaStream_t stream );
short cols, short rows, cudaStream_t stream ) const;

__host__ __device__ inline const T* ptr( int y ) const {
return (const T*)( (const char*)this->data + y * _pitchInBytes );
Expand Down Expand Up @@ -219,7 +220,7 @@ inline void PitchPlane2D<T>::memcpyFromHost( PitchPlane2D<T>& hostPlane, short c

template <typename T>
__host__
inline void PitchPlane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane, short cols, short rows )
inline void PitchPlane2D<T>::memcpyFromDevice( const PitchPlane2D<T>& devPlane, short cols, short rows )
{
PlaneBase::memcpyToHost( this->data, this->_pitchInBytes,
devPlane.data, devPlane._pitchInBytes,
Expand All @@ -229,7 +230,7 @@ inline void PitchPlane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane, short

template <typename T>
__host__
inline void PitchPlane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane, short cols, short rows, cudaStream_t stream )
inline void PitchPlane2D<T>::memcpyFromDevice( const PitchPlane2D<T>& devPlane, short cols, short rows, cudaStream_t stream )
{
PlaneBase::memcpyToHost( this->data, this->_pitchInBytes,
devPlane.data, devPlane._pitchInBytes,
Expand All @@ -240,14 +241,14 @@ inline void PitchPlane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane, short

template <typename T>
__host__
inline void PitchPlane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, short cols, short rows )
inline void PitchPlane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, short cols, short rows ) const
{
hostPlane.memcpyFromDevice( *this, cols, rows );
}

template <typename T>
__host__
inline void PitchPlane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, short cols, short rows, cudaStream_t stream )
inline void PitchPlane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, short cols, short rows, cudaStream_t stream ) const
{
hostPlane.memcpyFromDevice( *this, cols, rows, stream );
}
Expand Down Expand Up @@ -319,17 +320,17 @@ template <typename T> class Plane2D : public PitchPlane2D<T>

/** cuda memcpy from parameter (plane allocated on device) to
* this (plane allocated on host) */
__host__ inline void memcpyFromDevice( Plane2D<T>& devPlane );
__host__ inline void memcpyFromDevice( PitchPlane2D<T>& devPlane );
__host__ inline void memcpyFromDevice( Plane2D<T>& devPlane, cudaStream_t stream );
__host__ inline void memcpyFromDevice( PitchPlane2D<T>& devPlane, cudaStream_t stream );
__host__ inline void memcpyFromDevice( const Plane2D<T>& devPlane );
__host__ inline void memcpyFromDevice( const PitchPlane2D<T>& devPlane );
__host__ inline void memcpyFromDevice( const Plane2D<T>& devPlane, cudaStream_t stream );
__host__ inline void memcpyFromDevice( const PitchPlane2D<T>& devPlane, cudaStream_t stream );

/** cuda memcpy from this (plane allocated on device) to
* parameter (plane allocated on host) */
__host__ inline void memcpyToHost( Plane2D<T>& hostPlane );
__host__ inline void memcpyToHost( Plane2D<T>& hostPlane, cudaStream_t stream );
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane );
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane, cudaStream_t stream );
__host__ inline void memcpyToHost( Plane2D<T>& hostPlane ) const;
__host__ inline void memcpyToHost( Plane2D<T>& hostPlane, cudaStream_t stream ) const;
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane ) const;
__host__ inline void memcpyToHost( PitchPlane2D<T>& hostPlane, cudaStream_t stream ) const;

__host__ __device__
inline short getCols( ) const { return _cols; }
Expand Down Expand Up @@ -460,7 +461,7 @@ inline void Plane2D<T>::memcpyFromHost( PitchPlane2D<T>& hostPlane, cudaStream_t

template <typename T>
__host__
inline void Plane2D<T>::memcpyFromDevice( Plane2D<T>& devPlane )
inline void Plane2D<T>::memcpyFromDevice( const Plane2D<T>& devPlane )
{
assert( devPlane._cols == this->_cols );
assert( devPlane._rows == this->_rows );
Expand All @@ -469,14 +470,14 @@ inline void Plane2D<T>::memcpyFromDevice( Plane2D<T>& devPlane )

template <typename T>
__host__
inline void Plane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane )
inline void Plane2D<T>::memcpyFromDevice( const PitchPlane2D<T>& devPlane )
{
PitchPlane2D<T>::memcpyFromDevice( devPlane, this->_cols, this->_rows );
}

template <typename T>
__host__
inline void Plane2D<T>::memcpyFromDevice( Plane2D<T>& devPlane, cudaStream_t stream )
inline void Plane2D<T>::memcpyFromDevice( const Plane2D<T>& devPlane, cudaStream_t stream )
{
assert( devPlane._cols == this->_cols );
assert( devPlane._rows == this->_rows );
Expand All @@ -485,35 +486,35 @@ inline void Plane2D<T>::memcpyFromDevice( Plane2D<T>& devPlane, cudaStream_t str

template <typename T>
__host__
inline void Plane2D<T>::memcpyFromDevice( PitchPlane2D<T>& devPlane, cudaStream_t stream )
inline void Plane2D<T>::memcpyFromDevice( const PitchPlane2D<T>& devPlane, cudaStream_t stream )
{
PitchPlane2D<T>::memcpyFromDevice( devPlane, this->_cols, this->_rows, stream );
}

template <typename T>
__host__
inline void Plane2D<T>::memcpyToHost( Plane2D<T>& hostPlane )
inline void Plane2D<T>::memcpyToHost( Plane2D<T>& hostPlane ) const
{
hostPlane.memcpyFromDevice( *this );
}

template <typename T>
__host__
inline void Plane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane )
inline void Plane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane ) const
{
hostPlane.memcpyFromDevice( *this, this->_cols, this->_rows );
}

template <typename T>
__host__
inline void Plane2D<T>::memcpyToHost( Plane2D<T>& hostPlane, cudaStream_t stream )
inline void Plane2D<T>::memcpyToHost( Plane2D<T>& hostPlane, cudaStream_t stream ) const
{
hostPlane.memcpyFromDevice( *this, stream );
}

template <typename T>
__host__
inline void Plane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, cudaStream_t stream )
inline void Plane2D<T>::memcpyToHost( PitchPlane2D<T>& hostPlane, cudaStream_t stream ) const
{
hostPlane.memcpyFromDevice( *this, this->_cols, this->_rows, stream );
}
Expand Down
12 changes: 6 additions & 6 deletions src/popsift/common/write_plane_2d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace std;
namespace popsift {

__host__
void write_plane2D( const char* filename, bool onDevice, Plane2D_float& f )
void write_plane2D( const char* filename, bool onDevice, const Plane2D_float& f )
{
if( onDevice ) {
// cerr << __FILE__ << ":" << __LINE__ << ": copying from device" << endl;
Expand All @@ -32,7 +32,7 @@ void write_plane2D( const char* filename, bool onDevice, Plane2D_float& f )
}

__host__
void write_plane2Dunscaled( const char* filename, bool onDevice, Plane2D_float& f, int offset )
void write_plane2Dunscaled( const char* filename, bool onDevice, const Plane2D_float& f, int offset )
{
if( onDevice ) {
// cerr << __FILE__ << ":" << __LINE__ << ": copying from device" << endl;
Expand All @@ -47,7 +47,7 @@ void write_plane2Dunscaled( const char* filename, bool onDevice, Plane2D_float&
}

__host__
void write_plane2D( const char* filename, Plane2D_float& f )
void write_plane2D( const char* filename, const Plane2D_float& f )
{
// cerr << "Enter " << __FUNCTION__ << endl;

Expand Down Expand Up @@ -107,7 +107,7 @@ void write_plane2D( const char* filename, Plane2D_float& f )
}

__host__
void write_plane2Dunscaled( const char* filename, Plane2D_float& f, int offset )
void write_plane2Dunscaled( const char* filename, const Plane2D_float& f, int offset )
{
int rows = f.getRows();
int cols = f.getCols();
Expand Down Expand Up @@ -139,7 +139,7 @@ void write_plane2Dunscaled( const char* filename, Plane2D_float& f, int offset )
}

__host__
void dump_plane2Dfloat( const char* filename, bool onDevice, Plane2D_float& f )
void dump_plane2Dfloat( const char* filename, bool onDevice, const Plane2D_float& f )
{
if( onDevice ) {
// cerr << __FILE__ << ":" << __LINE__ << ": copying from device" << endl;
Expand All @@ -154,7 +154,7 @@ void dump_plane2Dfloat( const char* filename, bool onDevice, Plane2D_float& f )
}

__host__
void dump_plane2Dfloat( const char* filename, Plane2D_float& f )
void dump_plane2Dfloat( const char* filename, const Plane2D_float& f )
{
int rows = f.getRows();
int cols = f.getCols();
Expand Down
12 changes: 6 additions & 6 deletions src/popsift/common/write_plane_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace popsift {

void write_plane2D( const char* filename, bool onDevice, Plane2D_float& f );
void write_plane2D( const char* filename, Plane2D_float& f );
void write_plane2D( const char* filename, bool onDevice, const Plane2D_float& f );
void write_plane2D( const char* filename, const Plane2D_float& f );

void write_plane2Dunscaled( const char* filename, bool onDevice, Plane2D_float& f, int offset=0 );
void write_plane2Dunscaled( const char* filename, Plane2D_float& f, int offset=0 );
void write_plane2Dunscaled( const char* filename, bool onDevice, const Plane2D_float& f, int offset=0 );
void write_plane2Dunscaled( const char* filename, const Plane2D_float& f, int offset=0 );

void dump_plane2Dfloat( const char* filename, bool onDevice, Plane2D_float& f );
void dump_plane2Dfloat( const char* filename, Plane2D_float& f );
void dump_plane2Dfloat( const char* filename, bool onDevice, const Plane2D_float& f );
void dump_plane2Dfloat( const char* filename, const Plane2D_float& f );
} // namespace popsift

6 changes: 3 additions & 3 deletions src/popsift/sift_octave.cu
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void Octave::download_and_save_array( const char* basename, int octave )
POP_CUDA_FATAL_TEST(err, "cudaMemcpy3D failed: ");

for( int l = 0; l<_levels; l++ ) {
Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));
const Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));

ostringstream ostr;
ostr << "dir-octave/" << basename << "-o-" << octave << "-l-" << l << ".pgm";
Expand All @@ -173,7 +173,7 @@ void Octave::download_and_save_array( const char* basename, int octave )
POP_CUDA_FATAL_TEST(err, "cudaMemcpy3D failed: ");

for( int l = 0; l<_levels; l++ ) {
Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));
const Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));

ostringstream ostr;
ostr << "dir-interm/" << basename << "-o-" << octave << "-l-" << l << ".pgm";
Expand All @@ -189,7 +189,7 @@ void Octave::download_and_save_array( const char* basename, int octave )
POP_CUDA_FATAL_TEST(err, "cudaMemcpy3D failed: ");

for (int l = 0; l<_levels - 1; l++) {
Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));
const Plane2D_float p(width, height, &array[l*width*height], width * sizeof(float));

ostringstream ostr;
ostr << "dir-dog/d-" << basename << "-o-" << octave << "-l-" << l << ".pgm";
Expand Down