-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CUDA Max Blocks Fix #612
base: develop
Are you sure you want to change the base?
CUDA Max Blocks Fix #612
Changes from all commits
9774431
1ad17c0
8cf5011
939f3f1
82b56e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,8 +301,13 @@ struct CudaLaunchHelper<cuda_launch<async0, num_blocks, num_threads>,StmtList,Da | |
} | ||
} | ||
|
||
// | ||
// actual_threads can be modified in the case where | ||
// the requested number of theads would cause the | ||
// max_blocks to be 0 | ||
// | ||
inline static void max_blocks(int shmem_size, | ||
int &max_blocks, int actual_threads) | ||
int &max_blocks, int &actual_threads) | ||
{ | ||
auto func = internal::CudaKernelLauncher<Data, executor_t>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the fixed kernel launch function if num_threads is greater than zero. |
||
|
||
|
@@ -314,6 +319,23 @@ struct CudaLaunchHelper<cuda_launch<async0, num_blocks, num_threads>,StmtList,Da | |
internal::cuda_occupancy_max_blocks<Self>( | ||
func, shmem_size, max_blocks, actual_threads); | ||
|
||
if(max_blocks == 0) { | ||
|
||
// | ||
// actual_threads is too high for the kernel to run | ||
// successfully due to resource constraints reset to | ||
// something that is possible | ||
// | ||
int min_grid_size, max_block_size; | ||
// NOTE: min_grid_size is the minimum grid size needed | ||
// to achieve the best potential occupancy | ||
internal::cuda_occupancy_max_blocks_threads<Self>( | ||
func, shmem_size, min_grid_size, max_block_size); | ||
actual_threads = max_block_size; | ||
max_blocks = min_grid_size; | ||
} | ||
|
||
|
||
} else { | ||
|
||
// | ||
|
@@ -477,7 +499,17 @@ struct StatementExecutor< | |
// Compute the MAX physical kernel blocks | ||
// | ||
int max_blocks; | ||
launch_t::max_blocks(shmem, max_blocks, launch_dims.num_threads()); | ||
int adjusted_threads = launch_dims.num_threads(); | ||
launch_t::max_blocks(shmem, max_blocks, adjusted_threads); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The adjusted_threads should be corrected if less than min_threads |
||
|
||
// | ||
// Redo fit with adjusted_threads | ||
// | ||
if(launch_dims.num_threads() != adjusted_threads) { | ||
fit_threads = fitCudaDims( | ||
adjusted_threads, launch_dims.threads, launch_dims.min_threads); | ||
launch_dims.threads = fit_threads; | ||
} | ||
|
||
int use_blocks; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual_threads should not be changed at this point if num_threads was specified at compile-time.