Skip to content

Commit

Permalink
Control number of workers
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdp committed Oct 13, 2023
1 parent 6a3be98 commit 4a87430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions backend/src/backend/experiments/calc_surf_isec_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ async def calc_surf_isec_custom(
name: str,
attribute: str,
num_reals: int,
num_workers: int,
cutting_plane: schemas.CuttingPlane,
) -> List[schemas.SurfaceIntersectionData]:

myprefix = ">>>>>>>>>>>>>>>>> calc_surf_isec_custom():"
print(f"{myprefix} started with {num_reals=}", flush=True)
print(f"{myprefix} started with {num_reals=} {num_workers=}", flush=True)

perf_metrics.reset_lap_timer()

Expand All @@ -63,7 +64,7 @@ async def calc_surf_isec_custom(
multi_queue = multiprocessing.Queue()
async_queue = AsyncQueue(multi_queue)

num_procs=4
num_procs=num_workers
proc_arr = []
for proc_num in range(num_procs):
p = multiprocessing.Process(target=process_surf_worker, args=(f"sigworker{proc_num}", multi_queue, fence_arr))
Expand Down Expand Up @@ -95,7 +96,8 @@ async def calc_surf_isec_custom(

async def load_surf_bytes_task(queue, access: SurfaceAccess, real_num: int, name: str, attribute: str):
surf_bytes = await access.get_realization_surface_bytes_async(real_num=real_num, name=name, attribute=attribute)
await queue.put(surf_bytes)
if surf_bytes is not None:
await queue.put(surf_bytes)


def process_surf_worker(workerName, queue, fence_arr):
Expand Down
2 changes: 1 addition & 1 deletion backend/src/backend/user_session/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def post_calc_surf_isec_experiments(
#intersections = await calc_surf_isec_fetch_first(perf_metrics, authenticated_user, case_uuid, ensemble_name, name, attribute, num_reals, cutting_plane)
#intersections = await calc_surf_isec_queue(perf_metrics, authenticated_user, case_uuid, ensemble_name, name, attribute, num_reals, num_workers, cutting_plane)
#intersections = await calc_surf_isec_multiprocess(perf_metrics, authenticated_user, case_uuid, ensemble_name, name, attribute, num_reals, cutting_plane)
intersections = await calc_surf_isec_custom(perf_metrics, authenticated_user, case_uuid, ensemble_name, name, attribute, num_reals, cutting_plane)
intersections = await calc_surf_isec_custom(perf_metrics, authenticated_user, case_uuid, ensemble_name, name, attribute, num_reals, num_workers, cutting_plane)

LOGGER.debug(f"route calc_surf_isec_experiments - intersected {len(intersections)} surfaces in: {perf_metrics.to_string()}")

Expand Down

0 comments on commit 4a87430

Please sign in to comment.