Skip to content

Commit

Permalink
Merge pull request #68 from glotzerlab/modify-sdf-pressure-projects
Browse files Browse the repository at this point in the history
Modify sdf pressure projects for performance
  • Loading branch information
joaander authored Oct 30, 2023
2 parents 164a106 + d66992c commit 03b7ed3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 82 deletions.
51 changes: 9 additions & 42 deletions hoomd_validation/patchy_particle_pressure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ def is_patchy_particle_pressure_positive_pressure(job):
select=is_patchy_particle_pressure_positive_pressure,
)

partition_jobs_gpu = aggregator.groupsof(
num=min(CONFIG["replicates"], CONFIG["max_gpus_submission"]),
sort_by='density',
select=is_patchy_particle_pressure,
)


def _single_patch_kern_frenkel_code(delta_rad, sq_well_lambda, sigma, kT,
long_range_interaction_scale_factor):
Expand Down Expand Up @@ -551,33 +545,13 @@ def run_npt_sim(job, device, complete_filename):
},
]

if CONFIG["enable_gpu"]:
job_definitions = []
job_definitions.extend([
{
'mode': 'nvt',
'device_name': 'gpu',
'ranks_per_partition': 1,
'aggregator': partition_jobs_gpu
},
{
'mode': 'npt',
'device_name': 'gpu',
'ranks_per_partition': 1,
'aggregator': partition_jobs_gpu
},
])


def add_sampling_job(mode, device_name, ranks_per_partition, aggregator):
"""Add a sampling job to the workflow."""
directives = dict(walltime=CONFIG["max_walltime"],
executable=CONFIG["executable"],
nranks=util.total_ranks_function(ranks_per_partition))

if device_name == 'gpu':
directives['ngpu'] = directives['nranks']

@Project.pre.after(patchy_particle_pressure_create_initial_state)
@Project.post.isfile(f'{mode}_{device_name}_complete')
@Project.operation(name=f'patchy_particle_pressure_{mode}_{device_name}',
Expand All @@ -595,14 +569,9 @@ def sampling_operation(*jobs):
print(f'starting patchy_particle_pressure_{mode}_{device_name}:',
job)

if device_name == 'gpu':
device_cls = hoomd.device.GPU
elif device_name == 'cpu':
device_cls = hoomd.device.CPU

device = device_cls(communicator=communicator,
message_filename=util.get_message_filename(
job, f'{mode}_{device_name}.log'))
device = hoomd.device.CPU(communicator=communicator,
message_filename=util.get_message_filename(
job, f'{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down Expand Up @@ -636,9 +605,8 @@ def patchy_particle_pressure_analyze(job):

sim_modes = []
for _ensemble in ['nvt', 'npt']:
for _device in ['cpu', 'gpu']:
if job.isfile(f'{_ensemble}_{_device}_quantities.gsd'):
sim_modes.append(f'{_ensemble}_{_device}')
if job.isfile(f'{_ensemble}_cpu_quantities.gsd'):
sim_modes.append(f'{_ensemble}_cpu')

util._sort_sim_modes(sim_modes)

Expand Down Expand Up @@ -706,7 +674,7 @@ def patchy_particle_pressure_analyze(job):
f"T={job.sp.temperature}, "
f"$\\chi={job.sp.chi}$, "
f"replicate={job.statepoint.replicate_idx}, "
r"$\\varepsilon_{\mathrm{rep}}/\\varepsilon_{\mathrm{att}}$"
"$\\varepsilon_{\\mathrm{rep}}/\\varepsilon_{\\mathrm{att}}$"
f"$={job.sp.long_range_interaction_scale_factor}$")
fig.savefig(job.fn('nvt_npt_plots.svg'),
bbox_inches='tight',
Expand Down Expand Up @@ -743,9 +711,8 @@ def patchy_particle_pressure_compare_modes(*jobs):

sim_modes = []
for _ensemble in ['nvt', 'npt']:
for _device in ['cpu', 'gpu']:
if jobs[0].isfile(f'{_ensemble}_{_device}_quantities.gsd'):
sim_modes.append(f'{_ensemble}_{_device}')
if jobs[0].isfile(f'{_ensemble}_cpu_quantities.gsd'):
sim_modes.append(f'{_ensemble}_cpu')

util._sort_sim_modes(sim_modes)

Expand All @@ -771,7 +738,7 @@ def patchy_particle_pressure_compare_modes(*jobs):
f"$N={num_particles}$, "
f"T={set_temperature}, "
f"$\\chi={set_chi}$, "
r"$\\varepsilon_{\mathrm{rep}}/\\varepsilon_{\mathrm{att}}$"
"$\\varepsilon_{\\mathrm{rep}}/\\varepsilon_{\\mathrm{att}}$"
f"$={lrisf}$")

for i, quantity_name in enumerate(quantity_names):
Expand Down
48 changes: 8 additions & 40 deletions hoomd_validation/simple_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Step counts must be even and a multiple of the log quantity period.
RANDOMIZE_STEPS = 20_000
EQUILIBRATE_STEPS = 100_000
RUN_STEPS = 2_500_000
RUN_STEPS = 500_000
RESTART_STEPS = RUN_STEPS // 50
TOTAL_STEPS = RANDOMIZE_STEPS + EQUILIBRATE_STEPS + RUN_STEPS
SHAPE_VERTICES = [
Expand Down Expand Up @@ -70,11 +70,6 @@ def is_simple_polygon(job):
sort_by='density',
select=is_simple_polygon)

partition_jobs_gpu = aggregator.groupsof(num=min(CONFIG["replicates"],
CONFIG["max_gpus_submission"]),
sort_by='density',
select=is_simple_polygon)


@Project.post.isfile('simple_polygon_initial_state.gsd')
@Project.operation(directives=dict(
Expand Down Expand Up @@ -438,33 +433,13 @@ def run_npt_sim(job, device, complete_filename):
},
]

job_definitions = []
if CONFIG["enable_gpu"]:
job_definitions.extend([
{
'mode': 'nvt',
'device_name': 'gpu',
'ranks_per_partition': 1,
'aggregator': partition_jobs_gpu
},
{
'mode': 'npt',
'device_name': 'gpu',
'ranks_per_partition': 1,
'aggregator': partition_jobs_gpu
},
])


def add_sampling_job(mode, device_name, ranks_per_partition, aggregator):
"""Add a sampling job to the workflow."""
directives = dict(walltime=CONFIG["max_walltime"],
executable=CONFIG["executable"],
nranks=util.total_ranks_function(ranks_per_partition))

if device_name == 'gpu':
directives['ngpu'] = directives['nranks']

@Project.pre.after(simple_polygon_create_initial_state)
@Project.post.isfile(f'{mode}_{device_name}_complete')
@Project.operation(name=f'simple_polygon_{mode}_{device_name}',
Expand All @@ -481,14 +456,9 @@ def sampling_operation(*jobs):
if communicator.rank == 0:
print(f'starting simple_polygon_{mode}_{device_name}:', job)

if device_name == 'gpu':
device_cls = hoomd.device.GPU
elif device_name == 'cpu':
device_cls = hoomd.device.CPU

device = device_cls(communicator=communicator,
message_filename=util.get_message_filename(
job, f'{mode}_{device_name}.log'))
device = hoomd.device.CPU(communicator=communicator,
message_filename=util.get_message_filename(
job, f'{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down Expand Up @@ -521,9 +491,8 @@ def simple_polygon_analyze(job):

sim_modes = []
for _ensemble in ['nvt', 'npt']:
for _device in ['cpu', 'gpu']:
if job.isfile(f'{_ensemble}_{_device}_quantities.gsd'):
sim_modes.append(f'{_ensemble}_{_device}')
if job.isfile(f'{_ensemble}_cpu_quantities.gsd'):
sim_modes.append(f'{_ensemble}_cpu')

util._sort_sim_modes(sim_modes)

Expand Down Expand Up @@ -594,9 +563,8 @@ def simple_polygon_compare_modes(*jobs):

sim_modes = []
for _ensemble in ['nvt', 'npt']:
for _device in ['cpu', 'gpu']:
if jobs[0].isfile(f'{_ensemble}_{_device}_quantities.gsd'):
sim_modes.append(f'{_ensemble}_{_device}')
if jobs[0].isfile(f'{_ensemble}_cpu_quantities.gsd'):
sim_modes.append(f'{_ensemble}_cpu')

util._sort_sim_modes(sim_modes)

Expand Down

0 comments on commit 03b7ed3

Please sign in to comment.