This commit is contained in:
Hendrik Groove 2024-10-21 00:32:33 +02:00
parent 1f4154d756
commit ed1636b9c0

View File

@ -996,19 +996,20 @@ auto Reduce(Policy policy, InputIt first, InputIt second, Init init, Func reduce
std::cerr << "Processing batch: offset=" << offset << ", batch_size=" << batch_size << std::endl;
try {
// Get the raw pointers for debugging
auto raw_begin = thrust::raw_pointer_cast(&*begin_it);
auto raw_end = thrust::raw_pointer_cast(&*end_it);
std::cerr << "Raw pointers - begin: " << (const void*)raw_begin
<< ", end: " << (const void*)raw_end << std::endl;
// Instead of trying to get raw pointers, let's print the iterator types
std::cerr << "Iterator types - begin: " << typeid(begin_it).name()
<< ", end: " << typeid(end_it).name() << std::endl;
// Check if the pointers are valid device pointers
// If we need to check pointer validity, we can do it like this:
if (batch_size > 0) {
auto& first_element = *begin_it;
hipPointerAttribute_t attrs;
hipError_t ptr_err = hipPointerGetAttributes(&attrs, raw_begin);
hipError_t ptr_err = hipPointerGetAttributes(&attrs, &first_element);
if (ptr_err != hipSuccess) {
std::cerr << "Invalid begin pointer: " << hipGetErrorString(ptr_err) << std::endl;
std::cerr << "Invalid pointer for first element: " << hipGetErrorString(ptr_err) << std::endl;
} else {
std::cerr << "Valid begin pointer, memory type: " << attrs.type << std::endl;
std::cerr << "Valid pointer for first element, memory type: " << attrs.type << std::endl;
}
}
auto ret = thrust::reduce(policy, begin_it, end_it, init, reduce_op);