Skip to content

Commit

Permalink
Properly cast allocated pointer from void* to size_type*
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Jan 21, 2024
1 parent 17f7ffb commit 237475e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions core/src/Cuda/Kokkos_Cuda_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ Cuda::size_type *CudaInternal::scratch_flags(const std::size_t size) const {

std::size_t alloc_size =
multiply_overflow_abort(m_scratchFlagsCount, sizeScratchGrain);
m_scratchFlags =
mem_space.allocate("Kokkos::InternalScratchFlags", alloc_size);
m_scratchFlags = static_cast<size_type *>(
mem_space.allocate("Kokkos::InternalScratchFlags", alloc_size));

KOKKOS_IMPL_CUDA_SAFE_CALL(
(cuda_memset_wrapper(m_scratchFlags, 0, alloc_size)));
Expand All @@ -369,8 +369,8 @@ Cuda::size_type *CudaInternal::scratch_space(const std::size_t size) const {

std::size_t alloc_size =
multiply_overflow_abort(m_scratchSpaceCount, sizeScratchGrain);
m_scratchSpace =
mem_space.allocate("Kokkos::InternalScratchSpace", alloc_size);
m_scratchSpace = static_cast<size_type *>(
mem_space.allocate("Kokkos::InternalScratchSpace", alloc_size));
}

return m_scratchSpace;
Expand All @@ -390,8 +390,8 @@ Cuda::size_type *CudaInternal::scratch_unified(const std::size_t size) const {

std::size_t alloc_size =
multiply_overflow_abort(m_scratchUnifiedCount, sizeScratchGrain);
m_scratchUnified =
mem_space.allocate("Kokkos::InternalScratchUnified", alloc_size);
m_scratchUnified = static_cast<size_type *>(
mem_space.allocate("Kokkos::InternalScratchUnified", alloc_size));
}

return m_scratchUnified;
Expand All @@ -407,8 +407,8 @@ Cuda::size_type *CudaInternal::scratch_functor(const std::size_t size) const {
mem_space.deallocate(m_scratchFunctor, std::size_t(-1)); // FIXME
}

m_scratchFunctor = mem_space.allocate("Kokkos::InternalScratchFunctor",
m_scratchFunctorSize);
m_scratchFunctor = static_cast<size_type *>(mem_space.allocate(
"Kokkos::InternalScratchFunctor", m_scratchFunctorSize));
}

return m_scratchFunctor;
Expand Down
16 changes: 8 additions & 8 deletions core/src/HIP/Kokkos_HIP_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ Kokkos::HIP::size_type *HIPInternal::scratch_space(const std::size_t size) {

std::size_t alloc_size =
multiply_overflow_abort(m_scratchSpaceCount, sizeScratchGrain);
m_scratchSpace =
mem_space.allocate("Kokkos::InternalScratchSpace", alloc_size);
m_scratchSpace = static_cast<size_type *>(
mem_space.allocate("Kokkos::InternalScratchSpace", alloc_size));
}

return m_scratchSpace;
Expand All @@ -221,8 +221,8 @@ Kokkos::HIP::size_type *HIPInternal::scratch_flags(const std::size_t size) {

std::size_t alloc_size =
multiply_overflow_abort(m_scratchFlagsCount, sizeScratchGrain);
m_scratchFlags =
mem_space.allocate("Kokkos::InternalScratchFlags", alloc_size);
m_scratchFlags = static_cast<size_type *>(
mem_space.allocate("Kokkos::InternalScratchFlags", alloc_size));

KOKKOS_IMPL_HIP_SAFE_CALL(hipMemset(m_scratchFlags, 0, alloc_size));
}
Expand All @@ -244,10 +244,10 @@ Kokkos::HIP::size_type *HIPInternal::stage_functor_for_execution(
std::size_t(-1)); // FIXME
}

m_scratchFunctor = device_mem_space.allocate(
"Kokkos::InternalScratchFunctor", m_scratchFunctorSize);
m_scratchFunctorHost = host_mem_space.allocate(
"Kokkos::InternalScratchFunctorHost", m_scratchFunctorSize);
m_scratchFunctor = static_cast<size_type *>(device_mem_space.allocate(
"Kokkos::InternalScratchFunctor", m_scratchFunctorSize));
m_scratchFunctorHost = static_cast<size_type *>(host_mem_space.allocate(
"Kokkos::InternalScratchFunctorHost", m_scratchFunctorSize));
}

// When using HSA_XNACK=1, it is necessary to copy the driver to the host to
Expand Down
12 changes: 6 additions & 6 deletions core/src/SYCL/Kokkos_SYCL_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ sycl::device_ptr<void> SYCLInternal::scratch_space(const std::size_t size) {

std::size_t alloc_size = Kokkos::Impl::multiply_overflow_abort(
m_scratchSpaceCount, sizeScratchGrain);
m_scratchSpace = mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchSpace", alloc_size);
m_scratchSpace = static_cast<size_type*>(mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchSpace", alloc_size));
}

return m_scratchSpace;
Expand All @@ -261,8 +261,8 @@ sycl::host_ptr<void> SYCLInternal::scratch_host(const std::size_t size) {

std::size_t alloc_size = Kokkos::Impl::multiply_overflow_abort(
m_scratchHostCount, sizeScratchGrain);
m_scratchHost = mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchHost", alloc_size);
m_scratchHost = static_cast<size_type*>(mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchHost", alloc_size));
}

return m_scratchHost;
Expand All @@ -280,8 +280,8 @@ sycl::device_ptr<void> SYCLInternal::scratch_flags(const std::size_t size) {

std::size_t alloc_size = Kokkos::Impl::multiply_overflow_abort(
m_scratchFlagsCount, sizeScratchGrain);
m_scratchFlags = mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchFlags", alloc_size);
m_scratchFlags = static_cast<size_type*>(mem_space.allocate(
"Kokkos::Experimental::SYCL::InternalScratchFlags", alloc_size));
}
auto memset_event = m_queue->memset(m_scratchFlags, 0,
m_scratchFlagsCount * sizeScratchGrain);
Expand Down

0 comments on commit 237475e

Please sign in to comment.