Skip to content

Commit

Permalink
Fixed #560: Avoid GCC warnings regarding shadowing and narrowing conv…
Browse files Browse the repository at this point in the history
…ersions
  • Loading branch information
Eyal Rozenberg authored and Eyal Rozenberg committed Feb 15, 2024
1 parent ca3b01b commit 1c635b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
32 changes: 18 additions & 14 deletions src/cuda/api/copy_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ struct copy_parameters_t : detail_::base_copy_params_t<NumDimensions> {
return *this;
}

this_type& set_bytes_extent(dimensions_type extent) noexcept;
this_type& set_bytes_extent(dimensions_type extent_in_bytes) noexcept;

template<typename T>
this_type& set_extent(dimensions_type extent) noexcept;
this_type& set_extent(dimensions_type extent_in_elements) noexcept;
// Sets how much is being copies, as opposed to the sizes of the endpoints which may be larger

dimensions_type bytes_extent() const noexcept;
Expand Down Expand Up @@ -443,35 +443,39 @@ inline copy_parameters_t<3>& copy_parameters_t<3>::clear_rest() noexcept

template<>
template<typename T>
inline copy_parameters_t<2> &copy_parameters_t<2>::set_extent(dimensions_type extent) noexcept
inline copy_parameters_t<2> &copy_parameters_t<2>::set_extent(dimensions_type extent_in_elements) noexcept
{
WidthInBytes = extent.width * sizeof(T);
Height = extent.height;
WidthInBytes = extent_in_elements.width * sizeof(T);
Height = extent_in_elements.height;
return *this;
}

template<>
inline copy_parameters_t<2>& copy_parameters_t<2>::set_bytes_extent(dimensions_type extent) noexcept
inline copy_parameters_t<2>& copy_parameters_t<2>::set_bytes_extent(dimensions_type extent_in_elements) noexcept
{
WidthInBytes = extent.width;
Height = extent.height;
WidthInBytes = extent_in_elements.width;
Height = extent_in_elements.height;
return *this;
}

template<>
inline copy_parameters_t<3>& copy_parameters_t<3>::set_bytes_extent(dimensions_type extent) noexcept
inline copy_parameters_t<3>& copy_parameters_t<3>::set_bytes_extent(dimensions_type extent_in_elements) noexcept
{
WidthInBytes = extent.width;
Height = extent.height;
Depth = extent.depth;
WidthInBytes = extent_in_elements.width;
Height = extent_in_elements.height;
Depth = extent_in_elements.depth;
return *this;
}

template<>
template<typename T>
copy_parameters_t<3>& copy_parameters_t<3>::set_extent(dimensions_type extent) noexcept
copy_parameters_t<3>& copy_parameters_t<3>::set_extent(dimensions_type extent_in_elements) noexcept
{
dimensions_type extent_in_bytes{extent.width * sizeof(T), extent.height, extent.depth};
dimensions_type extent_in_bytes{
extent_in_elements.width * sizeof(T),
extent_in_elements.height,
extent_in_elements.depth
};
return set_bytes_extent(extent_in_bytes);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cuda/api/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ using size_t = ::std::size_t;
* The index or number of dimensions of an entity (as opposed to the extent in any
* dimension) - typically just 0, 1, 2 or 3.
*/
using dimensionality_t = unsigned;
using dimensionality_t = size_t;

namespace array {

Expand Down
14 changes: 8 additions & 6 deletions src/cuda/nvtx/profiling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,17 @@ inline void name_device<wchar_t>(device::id_t device_id, const wchar_t* name)

inline void name(::std::thread::id host_thread_id, const char* name)
{
auto native_handle = *(reinterpret_cast<const ::std::thread::native_handle_type*>(&host_thread_id));
uint32_t thread_id =
auto native_handle = *(reinterpret_cast<const ::std::thread::native_handle_type*>(&host_thread_id));
#ifdef _WIN32
GetThreadId(native_handle);
uint32_t thread_id = GetThreadId(native_handle);
#else
native_handle;
if (native_handle >= ::std::numeric_limits<uint32_t>::max()) {
throw ::std::runtime_error("Native thread ID " + ::std::to_string(native_handle) +
" exceeds maximum representable thread ID " + ::std::to_string(::std::numeric_limits<uint32_t>::max()));
}
auto thread_id = static_cast<uint32_t>(native_handle);
#endif
name_host_thread(thread_id, name);
}
name_host_thread(thread_id, name);}

} // namespace detail_

Expand Down

0 comments on commit 1c635b4

Please sign in to comment.