Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
fix issue #162 (cudaBindTexture returns cudaErrorInvalidValue if a me…
Browse files Browse the repository at this point in the history
…mory block from a pool allocator is passed)
  • Loading branch information
seunghwak authored and alliepiper committed Jul 30, 2021
1 parent 4aaed71 commit 01980f9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cub/device/dispatch/dispatch_spmv_orig.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ struct DispatchSpmv
if (CUB_IS_HOST_CODE)
{
// Init textures
if (CubDebug(error = spmv_params.t_vector_x.BindTexture(spmv_params.d_vector_x))) break;
if (CubDebug(error = spmv_params.t_vector_x.BindTexture(spmv_params.d_vector_x, spmv_params.num_cols * sizeof(ValueT)))) break;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion cub/iterator/tex_obj_input_iterator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public:
template <typename QualifiedT>
cudaError_t BindTexture(
QualifiedT *ptr, ///< Native pointer to wrap that is aligned to cudaDeviceProp::textureAlignment
size_t bytes = size_t(-1), ///< Number of bytes in the range
size_t bytes, ///< Number of bytes in the range
size_t tex_offset = 0) ///< OffsetT (in items) from \p ptr denoting the position of the iterator
{
this->ptr = const_cast<typename RemoveQualifiers<QualifiedT>::Type *>(ptr);
Expand Down
8 changes: 4 additions & 4 deletions cub/iterator/tex_ref_input_iterator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ struct CUB_DEPRECATED IteratorTexRef
static TexRef ref;

/// Bind texture
static cudaError_t BindTexture(void *d_in, size_t &offset)
static cudaError_t BindTexture(void *d_in, size_t &bytes, size_t &offset)
{
if (d_in)
{
cudaChannelFormatDesc tex_desc = cudaCreateChannelDesc<TextureWord>();
ref.channelDesc = tex_desc;
return (CubDebug(cudaBindTexture(&offset, ref, d_in)));
return (CubDebug(cudaBindTexture(&offset, ref, d_in, bytes)));
}

return cudaSuccess;
Expand Down Expand Up @@ -275,12 +275,12 @@ public:
template <typename QualifiedT>
cudaError_t BindTexture(
QualifiedT *ptr, ///< Native pointer to wrap that is aligned to cudaDeviceProp::textureAlignment
size_t /*bytes*/ = size_t(-1), ///< Number of bytes in the range
size_t bytes, ///< Number of bytes in the range
size_t tex_offset = 0) ///< OffsetT (in items) from \p ptr denoting the position of the iterator
{
this->ptr = const_cast<typename RemoveQualifiers<QualifiedT>::Type *>(ptr);
size_t offset;
cudaError_t retval = TexId::BindTexture(this->ptr + tex_offset, offset);
cudaError_t retval = TexId::BindTexture(this->ptr + tex_offset, bytes, offset);
this->tex_offset = (difference_type) (offset / sizeof(QualifiedT));
return retval;
}
Expand Down
2 changes: 1 addition & 1 deletion experimental/spmv_compare.cu
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ float TestGpuCsrIoProxy(

typedef TexRefInputIterator<ValueT, 1234, int> TexItr;
TexItr x_itr;
CubDebugExit(x_itr.BindTexture(params.d_vector_x));
CubDebugExit(x_itr.BindTexture(params.d_vector_x, params.num_cols * sizeof(ValueT)));

// Get device ordinal
int device_ordinal;
Expand Down

0 comments on commit 01980f9

Please sign in to comment.