This commit is contained in:
Hendrik Groove 2024-10-21 00:35:28 +02:00
parent ed1636b9c0
commit a135895f3a

View File

@ -995,16 +995,17 @@ auto Reduce(Policy policy, InputIt first, InputIt second, Init init, Func reduce
std::cerr << "Processing batch: offset=" << offset << ", batch_size=" << batch_size << std::endl; std::cerr << "Processing batch: offset=" << offset << ", batch_size=" << batch_size << std::endl;
try { try {
// Instead of trying to get raw pointers, let's print the iterator types // Print the iterator types
std::cerr << "Iterator types - begin: " << typeid(begin_it).name() std::cerr << "Iterator types - begin: " << typeid(begin_it).name()
<< ", end: " << typeid(end_it).name() << std::endl; << ", end: " << typeid(end_it).name() << std::endl;
// If we need to check pointer validity, we can do it like this: // If we need to check pointer validity, we can do it like this:
if (batch_size > 0) { if (batch_size > 0) {
auto& first_element = *begin_it; // Use thrust::raw_pointer_cast to get the underlying device pointer
auto raw_ptr = thrust::raw_pointer_cast(&(*begin_it));
hipPointerAttribute_t attrs; hipPointerAttribute_t attrs;
hipError_t ptr_err = hipPointerGetAttributes(&attrs, &first_element); hipError_t ptr_err = hipPointerGetAttributes(&attrs, raw_ptr);
if (ptr_err != hipSuccess) { if (ptr_err != hipSuccess) {
std::cerr << "Invalid pointer for first element: " << hipGetErrorString(ptr_err) << std::endl; std::cerr << "Invalid pointer for first element: " << hipGetErrorString(ptr_err) << std::endl;
} else { } else {