Skip to content

Commit

Permalink
molpro test updates
Browse files Browse the repository at this point in the history
Fixed local var min_mem_value

Update core reduction logic test for MP
  • Loading branch information
calvinp0 committed Feb 14, 2024
1 parent dc366c6 commit 2f581fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
14 changes: 7 additions & 7 deletions arc/job/adapters/molpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ def set_input_file_memory(self) -> None:
if available_cores < current_cpu_cores:
self.cpu_cores = available_cores
logger.info(f'Changing the number of cpu_cores from {current_cpu_cores} to {self.cpu_cores}')
# Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core)
# And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory.
# We will therefore, limit the MW to 4300 MW
self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores))
if self.cpu_cores == 1 and self.input_file_memory > min_memory_value:
self.input_file_memory = min_memory_value
logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro')
# Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core)
# And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory.
# We will therefore, limit the MW to 4300 MW
self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores))
if self.cpu_cores == 1 and self.input_file_memory > min_memory_value:
self.input_file_memory = min_memory_value
logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro')

def execute_incore(self):
"""
Expand Down
21 changes: 20 additions & 1 deletion arc/job/adapters/molpro_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ def setUpClass(cls):
job_memory_gb=64,
)

cls.job_5 = MolproAdapter(execution_type='queue',
job_type='opt',
level=Level(method='CCSD(T)', basis='cc-pVQZ'),
project='test',
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_MolproAdapter_2'),
species=[ARCSpecies(label='spc1', xyz=['O 0 0 1'])],
testing=True,
ess_trsh_methods=['memory','cpu', 'molpro_memory: 2800 '],
job_memory_gb=64,
)

def test_set_cpu_and_mem(self):
"""Test assigning number of cpu's and memory"""
self.job_1.cpu_cores = 48
Expand All @@ -84,7 +95,6 @@ def test_memory_change(self):
self.assertEqual(self.job_4.input_file_memory, 4300)
self.assertEqual(self.job_4.cpu_cores, 1)


def test_set_input_file_memory(self):
"""Test setting the input_file_memory argument"""
self.job_1.input_file_memory = None
Expand Down Expand Up @@ -161,6 +171,15 @@ def test_write_input_file(self):
"""
self.assertEqual(content_2, job_2_expected_input_file)

def test_core_reduction_logic(self):
"""Test the core reduction logic"""

# Job 5 again to trigger the condition of the core reduction logic
# Job 5 technically would be 3 CPUs prior to the reactive setting the input file memory.
self.job_5.set_input_file_memory()
self.assertEqual(self.job_5.input_file_memory, 4296)
self.assertEqual(self.job_5.cpu_cores, 2)

def test_set_files(self):
"""Test setting files"""
job_1_files_to_upload = [{'file_name': 'submit.sub',
Expand Down

0 comments on commit 2f581fd

Please sign in to comment.