Skip to content

Commit

Permalink
Cuda: Remove unused attach_texture_object
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed May 11, 2023
1 parent e94b5dd commit 0018848
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 103 deletions.
46 changes: 0 additions & 46 deletions core/src/Cuda/Kokkos_CudaSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,49 +423,6 @@ SharedAllocationRecord<void, void>
SharedAllocationRecord<Kokkos::CudaHostPinnedSpace, void>::s_root_record;
#endif

::cudaTextureObject_t
SharedAllocationRecord<Kokkos::CudaSpace, void>::attach_texture_object(
const unsigned sizeof_alias, void *const alloc_ptr,
size_t const alloc_size) {
enum { TEXTURE_BOUND_1D = 1u << 27 };

if ((alloc_ptr == nullptr) ||
(sizeof_alias * TEXTURE_BOUND_1D <= alloc_size)) {
std::ostringstream msg;
msg << "Kokkos::CudaSpace ERROR: Cannot attach texture object to"
<< " alloc_ptr(" << alloc_ptr << ")"
<< " alloc_size(" << alloc_size << ")"
<< " max_size(" << (sizeof_alias * TEXTURE_BOUND_1D) << ")";
std::cerr << msg.str() << std::endl;
std::cerr.flush();
Kokkos::Impl::throw_runtime_exception(msg.str());
}

::cudaTextureObject_t tex_obj;

struct cudaResourceDesc resDesc;
struct cudaTextureDesc texDesc;

memset(&resDesc, 0, sizeof(resDesc));
memset(&texDesc, 0, sizeof(texDesc));

resDesc.resType = cudaResourceTypeLinear;
resDesc.res.linear.desc =
(sizeof_alias == 4
? cudaCreateChannelDesc<int>()
: (sizeof_alias == 8
? cudaCreateChannelDesc< ::int2>()
:
/* sizeof_alias == 16 */ cudaCreateChannelDesc< ::int4>()));
resDesc.res.linear.sizeInBytes = alloc_size;
resDesc.res.linear.devPtr = alloc_ptr;

KOKKOS_IMPL_CUDA_SAFE_CALL(
cudaCreateTextureObject(&tex_obj, &resDesc, &texDesc, nullptr));

return tex_obj;
}

//==============================================================================
// <editor-fold desc="SharedAllocationRecord destructors"> {{{1

Expand Down Expand Up @@ -524,7 +481,6 @@ SharedAllocationRecord<Kokkos::CudaSpace, void>::SharedAllocationRecord(
arg_alloc_size),
sizeof(SharedAllocationHeader) + arg_alloc_size, arg_dealloc,
arg_label),
m_tex_obj(0),
m_space(arg_space) {

SharedAllocationHeader header;
Expand Down Expand Up @@ -555,7 +511,6 @@ SharedAllocationRecord<Kokkos::CudaSpace, void>::SharedAllocationRecord(
arg_label, arg_alloc_size),
sizeof(SharedAllocationHeader) + arg_alloc_size, arg_dealloc,
arg_label),
m_tex_obj(0),
m_space(arg_space) {

SharedAllocationHeader header;
Expand All @@ -582,7 +537,6 @@ SharedAllocationRecord<Kokkos::CudaUVMSpace, void>::SharedAllocationRecord(
arg_alloc_size),
sizeof(SharedAllocationHeader) + arg_alloc_size, arg_dealloc,
arg_label),
m_tex_obj(0),
m_space(arg_space) {
this->base_t::_fill_host_accessible_header_info(*base_t::m_alloc_ptr,
arg_label);
Expand Down
57 changes: 0 additions & 57 deletions core/src/Cuda/Kokkos_CudaSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,10 @@ class SharedAllocationRecord<Kokkos::CudaSpace, void>
SharedAllocationRecord(const SharedAllocationRecord&) = delete;
SharedAllocationRecord& operator=(const SharedAllocationRecord&) = delete;

static ::cudaTextureObject_t attach_texture_object(
const unsigned sizeof_alias, void* const alloc_ptr,
const size_t alloc_size);

#ifdef KOKKOS_ENABLE_DEBUG
static RecordBase s_root_record;
#endif

::cudaTextureObject_t m_tex_obj = 0;
const Kokkos::CudaSpace m_space;

protected:
Expand All @@ -566,7 +561,6 @@ class SharedAllocationRecord<Kokkos::CudaSpace, void>
arg_alloc_size),
sizeof(SharedAllocationHeader) + arg_alloc_size, arg_dealloc,
arg_label),
m_tex_obj(0),
m_space(arg_space) {

SharedAllocationHeader header;
Expand All @@ -592,30 +586,6 @@ class SharedAllocationRecord<Kokkos::CudaSpace, void>
// helper function to work around MSVC+NVCC issue
// https://github.com/kokkos/kokkos/issues/5258
static void deep_copy_header_no_exec(void*, const void*);

public:
template <typename AliasType>
inline ::cudaTextureObject_t attach_texture_object() {
static_assert((std::is_same<AliasType, int>::value ||
std::is_same<AliasType, ::int2>::value ||
std::is_same<AliasType, ::int4>::value),
"Cuda texture fetch only supported for alias types of int, "
"::int2, or ::int4");

if (m_tex_obj == 0) {
m_tex_obj = attach_texture_object(sizeof(AliasType),
(void*)RecordBase::m_alloc_ptr,
RecordBase::m_alloc_size);
}

return m_tex_obj;
}

template <typename AliasType>
inline int attach_texture_object_offset(const AliasType* const ptr) {
// Texture object is attached to the entire allocation range
return ptr - reinterpret_cast<AliasType*>(RecordBase::m_alloc_ptr);
}
};

template <>
Expand All @@ -632,7 +602,6 @@ class SharedAllocationRecord<Kokkos::CudaUVMSpace, void>

static RecordBase s_root_record;

::cudaTextureObject_t m_tex_obj = 0;
const Kokkos::CudaUVMSpace m_space;

protected:
Expand All @@ -657,7 +626,6 @@ class SharedAllocationRecord<Kokkos::CudaUVMSpace, void>
arg_alloc_size),
sizeof(SharedAllocationHeader) + arg_alloc_size, arg_dealloc,
arg_label),
m_tex_obj(0),
m_space(arg_space) {
this->base_t::_fill_host_accessible_header_info(*base_t::m_alloc_ptr,
arg_label);
Expand All @@ -667,31 +635,6 @@ class SharedAllocationRecord<Kokkos::CudaUVMSpace, void>
const Kokkos::CudaUVMSpace& arg_space, const std::string& arg_label,
const size_t arg_alloc_size,
const RecordBase::function_type arg_dealloc = &base_t::deallocate);

public:
template <typename AliasType>
inline ::cudaTextureObject_t attach_texture_object() {
static_assert((std::is_same<AliasType, int>::value ||
std::is_same<AliasType, ::int2>::value ||
std::is_same<AliasType, ::int4>::value),
"Cuda texture fetch only supported for alias types of int, "
"::int2, or ::int4");

if (m_tex_obj == 0) {
m_tex_obj = SharedAllocationRecord<Kokkos::CudaSpace, void>::
attach_texture_object(sizeof(AliasType),
(void*)RecordBase::m_alloc_ptr,
RecordBase::m_alloc_size);
}

return m_tex_obj;
}

template <typename AliasType>
inline int attach_texture_object_offset(const AliasType* const ptr) {
// Texture object is attached to the entire allocation range
return ptr - reinterpret_cast<AliasType*>(RecordBase::m_alloc_ptr);
}
};

template <>
Expand Down

0 comments on commit 0018848

Please sign in to comment.