Skip to content

Commit

Permalink
parallel build_all_MOR_seedpoints()
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchin committed May 20, 2024
1 parent 261e850 commit 3c29cac
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 168 deletions.
13 changes: 10 additions & 3 deletions gplately/commands/create_age_grids.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import datetime
import logging
import multiprocessing
import time
import warnings
from typing import Optional, Sequence, Union
Expand Down Expand Up @@ -112,9 +113,9 @@ def add_parser(parser: argparse.ArgumentParser):
agegrid_cmd.add_argument(
"-j",
"--n_jobs",
help="number of processes to use; default: 1",
help="number of processes to use; default: use all CPU available",
metavar="N_JOBS",
default=1,
default=None,
dest="n_jobs",
)
agegrid_cmd.add_argument(
Expand Down Expand Up @@ -226,6 +227,12 @@ def create_agegrids(


def _run_create_agegrids(args):
n_jobs = args.n_jobs
if not n_jobs:
try:
n_jobs = multiprocessing.cpu_count()
except NotImplementedError:
n_jobs = 1
start = time.time()

create_agegrids(
Expand All @@ -235,7 +242,7 @@ def _run_create_agegrids(args):
output_dir=args.output_dir,
min_time=args.min_time,
max_time=args.max_time,
n_jobs=args.n_jobs,
n_jobs=n_jobs,
refinement_levels=args.refinement_levels,
grid_spacing=args.grid_spacing,
ridge_sampling=args.ridge_sampling,
Expand Down
Loading

0 comments on commit 3c29cac

Please sign in to comment.