423 const uint thread_id = omp_get_thread_num();
425 const uint thread_id = 0;
433 for(
uint i = 0;
i < NDim;
i++) {
449 T *d_thread_data_dynamic = 0;
452 const uint gridsize = (
n_total - 1 + blocksize) / blocksize;
455 reduction_kernel<ARCH_BLOCKSIZE_R, Op, NDim, NReduStatic><<<gridsize, blocksize, 0,
gpuStreamList[thread_id]>>>(loop_body, d_const_buf, d_buf, d_limits,
n_total,
n_reductions, d_thread_data_dynamic);
478 T* d_thread_data_dynamic = 0;
479 if(NReduStatic == 0) {
481 constexpr auto cub_temp_storage_type_size =
sizeof(
typename hipcub::BlockReduce<T, ARCH_BLOCKSIZE_R, hipcub::BLOCK_REDUCE_RAKING_COMMUTATIVE_ONLY, 1, 1>::TempStorage);
482 constexpr auto cub_temp_storage_type_size_small =
sizeof(
typename hipcub::BlockReduce<T, ARCH_BLOCKSIZE_R_SMALL, hipcub::BLOCK_REDUCE_RAKING_COMMUTATIVE_ONLY, 1, 1>::TempStorage);
485 CHK_ERR(hipGetDevice(&device_id));
486 hipDeviceProp_t deviceProp;
487 CHK_ERR(hipGetDeviceProperties(&deviceProp, device_id));
490 size_t shared_mem_bytes_per_block_request;
491 if(
n_reductions * cub_temp_storage_type_size <= deviceProp.sharedMemPerBlock){
493 shared_mem_bytes_per_block_request =
n_reductions * cub_temp_storage_type_size;
495 else if(
n_reductions * cub_temp_storage_type_size_small <= deviceProp.sharedMemPerBlock){
497 shared_mem_bytes_per_block_request =
n_reductions * cub_temp_storage_type_size_small;
500 printf(
"The device %d (%s) does not have enough shared memory even for the small blocksize (%d)! The error occurred in %s at line %d\n", device_id, deviceProp.gcnArchName,
ARCH_BLOCKSIZE_R_SMALL, __FILE__, __LINE__);
504 const uint gridsize = (
n_total - 1 + blocksize) / blocksize;
510 reduction_kernel<ARCH_BLOCKSIZE_R, Op, NDim, 0><<<gridsize, blocksize, shared_mem_bytes_per_block_request,
gpuStreamList[thread_id]>>>(loop_body, d_const_buf, d_buf, d_limits,
n_total,
n_reductions, d_thread_data_dynamic);
513 reduction_kernel<ARCH_BLOCKSIZE_R_SMALL, Op, NDim, 0><<<gridsize, blocksize, shared_mem_bytes_per_block_request,
gpuStreamList[thread_id]>>>(loop_body, d_const_buf, d_buf, d_limits,
n_total,
n_reductions, d_thread_data_dynamic);
516 printf(
"The blocksize (%u) does not match with any of the predetermined block sizes! The error occurred in %s at line %d\n", blocksize, __FILE__, __LINE__);
529 const uint gridsize = (
n_total - 1 + blocksize) / blocksize;
532 reduction_kernel<ARCH_BLOCKSIZE_R, Op, NDim, NReduStatic><<<gridsize, blocksize, 0,
gpuStreamList[thread_id]>>>(loop_body, d_const_buf, d_buf, d_limits,
n_total,
n_reductions, d_thread_data_dynamic);