Skip to content

Commit

Permalink
Make sure we enable dev/shm when required (#555)
Browse files Browse the repository at this point in the history
* Make sure dev/shm is turned on when we're comparing results

* Pin dodal

* Add comment to explain constant

---------

Co-authored-by: Oliver Silvester <[email protected]>
Co-authored-by: olliesilvester <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2024
1 parent b557644 commit 7b3fe0a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def flyscan_xray_centre(
parameters.features.update_self_from_server()
composite.eiger.set_detector_parameters(parameters.detector_params)
composite.zocalo.zocalo_environment = parameters.zocalo_environment
composite.zocalo.use_cpu_and_gpu = parameters.use_cpu_and_gpu_zocalo
composite.zocalo.use_cpu_and_gpu = parameters.compare_cpu_and_gpu_results

feature_controlled = _get_feature_controlled(composite, parameters)

Expand Down
6 changes: 4 additions & 2 deletions src/mx_bluesky/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ class I03Constants:
OAV_CENTRING_FILE = _test_oav_file if TEST_MODE else _live_oav_file
SHUTTER_TIME_S = 0.06
USE_PANDA_FOR_GRIDSCAN = False
USE_GPU_FOR_GRIDSCAN_ANALYSIS = False
THAWING_TIME = 20
USE_CPU_AND_GPU_ZOCALO = False

# Turns on GPU processing for zocalo and logs a comparison between GPU and CPU-
# processed results. GPU results never used in analysis for now
COMPARE_CPU_AND_GPU_ZOCALO = False


@dataclass(frozen=True)
Expand Down
7 changes: 4 additions & 3 deletions src/mx_bluesky/hyperion/parameters/gridscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class GridCommon(
default=CONST.HARDWARE.PANDA_FGS_RUN_UP_DEFAULT
)
use_panda: bool = Field(default=CONST.I03.USE_PANDA_FOR_GRIDSCAN)
use_gpu: bool = Field(default=CONST.I03.USE_GPU_FOR_GRIDSCAN_ANALYSIS)
use_cpu_and_gpu_zocalo: bool = Field(default=CONST.I03.USE_CPU_AND_GPU_ZOCALO)
compare_cpu_and_gpu_results: bool = Field(
default=CONST.I03.COMPARE_CPU_AND_GPU_ZOCALO
)
ispyb_experiment_type: IspybExperimentType = Field(
default=IspybExperimentType.GRIDSCAN_3D
)
Expand Down Expand Up @@ -72,7 +73,7 @@ def detector_params(self):
use_roi_mode=self.use_roi_mode,
det_dist_to_beam_converter_path=self.det_dist_to_beam_converter_path,
trigger_mode=self.trigger_mode,
enable_dev_shm=self.use_gpu,
enable_dev_shm=self.compare_cpu_and_gpu_results,
**optional_args,
)

Expand Down
13 changes: 13 additions & 0 deletions tests/unit_tests/hyperion/parameters/test_parameter_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from pathlib import Path
from unittest.mock import patch

import pytest
from dodal.devices.aperturescatterguard import ApertureValue
Expand Down Expand Up @@ -120,3 +121,15 @@ def test_selected_aperture_uses_default():
raw_params["selected_aperture"] = None
params = RotationScan(**raw_params)
assert params.selected_aperture == ApertureValue.LARGE


@patch("mx_bluesky.hyperion.parameters.gridscan.os")
def test_gpu_enabled_if_use_gpu_or_compare_gpu_enabled(_, minimal_3d_gridscan_params):
minimal_3d_gridscan_params["detector_distance_mm"] = 100

grid_scan = ThreeDGridScan(**minimal_3d_gridscan_params)
assert not grid_scan.detector_params.enable_dev_shm

minimal_3d_gridscan_params["compare_cpu_and_gpu_results"] = True
grid_scan = ThreeDGridScan(**minimal_3d_gridscan_params)
assert grid_scan.detector_params.enable_dev_shm

0 comments on commit 7b3fe0a

Please sign in to comment.