Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdc/tests/test_prange_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def _get_chunks_data(self):
Chunk(start=3, stop=6),
Chunk(start=6, stop=9),
]
yield (0, 5), []
yield (5, 0), []

def _check_get_chunks(self, args, expected_chunks):
pyfunc = get_chunks
Expand Down
6 changes: 5 additions & 1 deletion sdc/utilities/prange_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ def get_pool_size():

@sdc_register_jitable
def get_chunks(size, pool_size):
chunks = []

if size < 1 or pool_size < 1:
return chunks

pool_size = min(pool_size, size)
chunk_size = size // pool_size
overload_size = size % pool_size

chunks = []
for i in range(pool_size):
start = i * chunk_size + min(i, overload_size)
stop = (i + 1) * chunk_size + min(i + 1, overload_size)
Expand Down