Skip to content

Commit

Permalink
Pass thread count optionally
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennings Zhang authored and Jennings Zhang committed Feb 1, 2023
1 parent 30eb1c8 commit b903305
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ep_surface_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
help='Produce exit code 0 even if any subprocesses do not.')
parser.add_argument('-V', '--version', action='version',
version=f'%(prog)s {__version__}')
parser.add_argument('-t', '--threads', type=int, default=0,
help='Number of threads to use for parallel jobs. '
'Pass 0 to use number of visible CPUs.')

parser.add_argument('--size', type=str, default='81920', help='number of polygons')
parser.add_argument('--stretch-weight', type=str, default='100', help='stretch weight')
Expand Down Expand Up @@ -87,7 +90,10 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
options.taubin
]

nproc = len(os.sched_getaffinity(0))
if options.threads > 0:
nproc = options.threads
else:
nproc = len(os.sched_getaffinity(0))
logger.info('Using {} threads.', nproc)

mapper = PathMapper.file_mapper(inputdir, outputdir, glob='**/*.mnc', suffix='.obj')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='ep_surface_fit',
version='0.4.2',
version='0.4.3',
description='surface_fit wrapper',
author='Jennings Zhang',
author_email='[email protected]',
Expand Down

0 comments on commit b903305

Please sign in to comment.