Skip to content
Snippets Groups Projects
Commit 1043b9ac authored by David Hendriks's avatar David Hendriks
Browse files

updating scaling plots. added pool closing and joining at the end of the MP...

updating scaling plots. added pool closing and joining at the end of the MP part because on astro2 I suddenly got the error of having too many open files
parent 7723404e
No related branches found
No related tags found
No related merge requests found
...@@ -812,6 +812,10 @@ class Population(object): ...@@ -812,6 +812,10 @@ class Population(object):
# TODO: calculate the chunksize value based on: total starcount and cores used. # TODO: calculate the chunksize value based on: total starcount and cores used.
r = list(p.imap_unordered(evolve_system, yield_system(), chunksize=20)) r = list(p.imap_unordered(evolve_system, yield_system(), chunksize=20))
# Handle clean termination of the whole multiprocessing
p.close()
p.join()
stop_mp = time.time() stop_mp = time.time()
# Give feedback # Give feedback
......
...@@ -78,10 +78,9 @@ ax1.set_xlim(0, max(cpus) + 4) ...@@ -78,10 +78,9 @@ ax1.set_xlim(0, max(cpus) + 4)
ax1.grid() ax1.grid()
ax1.legend(loc=4) ax1.legend(loc=4)
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "png")))
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "pdf")))
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "eps")))
plt.show() plt.show()
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "png")))
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "pdf")))
# fig.savefig(os.path.join(img_dir, "speedup_scaling_{}.{}".format(name_testcase, "eps")))
\ No newline at end of file
...@@ -10,10 +10,12 @@ from binarycpython.utils.functions import get_help_all, get_help, create_hdf5 ...@@ -10,10 +10,12 @@ from binarycpython.utils.functions import get_help_all, get_help, create_hdf5
import argparse import argparse
# Get some info
amount_of_cores = psutil.cpu_count(logical=False) amount_of_cores = psutil.cpu_count(logical=False)
amount_of_cpus = psutil.cpu_count() amount_of_cpus = psutil.cpu_count()
hostname = socket.gethostname() hostname = socket.gethostname()
# Generate list of cpu amounts to use
if amount_of_cpus <= 4: if amount_of_cpus <= 4:
stepsize = 1 stepsize = 1
elif 4 < amount_of_cpus <= 24: elif 4 < amount_of_cpus <= 24:
...@@ -28,13 +30,25 @@ for i in range(1, int(amount_of_cpus/stepsize) + 1 ): ...@@ -28,13 +30,25 @@ for i in range(1, int(amount_of_cpus/stepsize) + 1 ):
cpu_list.append(i * stepsize) cpu_list.append(i * stepsize)
# set some info
amt_repeats = 5 amt_repeats = 5
resolution = {'M_1': 5, 'per': 5}
resolution = {'M_1': 50, 'per': 50}
total_systems = int(np.prod([el for el in resolution.values()])) total_systems = int(np.prod([el for el in resolution.values()]))
result_dir = 'scaling_results' result_dir = 'scaling_results'
testcase = 'linear vs MP batched'
# Create dictionairy in which to store all the results:
result_dict = {}
#
result_dict['amt_systems'] = total_systems
result_dict['hostname'] = hostname
result_dict['amt_logical_cores'] = amount_of_cpus
result_dict['amt_of_physical_cores'] = amount_of_cores
result_dict['testcase'] = testcase
#################
# Configuring population
test_pop = Population() test_pop = Population()
test_pop.set( test_pop.set(
...@@ -48,8 +62,6 @@ test_pop.add_grid_variable( ...@@ -48,8 +62,6 @@ test_pop.add_grid_variable(
valuerange=[1, 100], valuerange=[1, 100],
resolution="{}".format(resolution['M_1']), resolution="{}".format(resolution['M_1']),
spacingfunc="const(1, 100, {})".format(resolution['M_1']), spacingfunc="const(1, 100, {})".format(resolution['M_1']),
precode="",
# precode="M_1=math.exp(lnm1)",
probdist="Kroupa2001(M_1)", probdist="Kroupa2001(M_1)",
# probdist='self.custom_options["extra_prob_function"](M_1)', # probdist='self.custom_options["extra_prob_function"](M_1)',
dphasevol="dlnm1", dphasevol="dlnm1",
...@@ -71,24 +83,14 @@ test_pop.add_grid_variable( ...@@ -71,24 +83,14 @@ test_pop.add_grid_variable(
) )
####################################################################################### #######################################################################################
# Execute grids
# Scaling dict:
result_dict = {}
#
result_dict['amt_systems'] = total_systems
# Linear runs # Linear runs
linear_times = [] linear_times = []
for repeat in range(amt_repeats): for repeat in range(amt_repeats):
total_lin_start = time.time() total_lin_start = time.time()
evolve_lin_time = test_pop.test_evolve_population_lin() evolve_lin_time = test_pop.test_evolve_population_lin()
total_lin = time.time() - total_lin_start
total_lin_stop = time.time()
total_lin = total_lin_stop - total_lin_start
print("linear run with {} systems: {} of which {} spent on evolving the systems".format(total_systems, total_lin, evolve_lin_time)) print("linear run with {} systems: {} of which {} spent on evolving the systems".format(total_systems, total_lin, evolve_lin_time))
linear_times.append(total_lin) linear_times.append(total_lin)
...@@ -96,31 +98,28 @@ for repeat in range(amt_repeats): ...@@ -96,31 +98,28 @@ for repeat in range(amt_repeats):
result_dict['linear'] = linear_times result_dict['linear'] = linear_times
####################################################################################### # #######################################################################################
# MP runs # # MP runs
mp_dict = {} # mp_dict = {}
for cpu_amt in cpu_list: # for cpu_amt in cpu_list:
mp_times = []
test_pop.set(amt_cores=cpu_amt)
# # mp_times = []
for repeat in range(amt_repeats):
# MP
total_mp_start = time.time()
evolve_mp_time = test_pop.evolve_population_mp_chunks() # test_pop.set(amt_cores=cpu_amt)
total_mp_stop = time.time()
total_mp = total_mp_stop - total_mp_start # #
mp_times.append(total_mp) # for repeat in range(amt_repeats):
print("MP ({} nodes) run with {} systems: {} of which {} spent on evolving the systems".format(cpu_amt, total_systems, total_mp, evolve_mp_time)) # total_mp_start = time.time()
# evolve_mp_time = test_pop.evolve_population_mp_chunks()
# total_mp = time.time() - total_mp_start
mp_dict[cpu_amt] = mp_times # print("MP ({} nodes) run with {} systems: {} of which {} spent on evolving the systems".format(cpu_amt, total_systems, total_mp, evolve_mp_time))
# mp_times.append(total_mp)
result_dict['mp'] = mp_dict # mp_dict[cpu_amt] = mp_times
# result_dict['mp'] = mp_dict
# Write to file
with open('scaling_results/{}_{}_systems.json'.format(hostname, total_systems), 'w') as f: with open('scaling_results/{}_{}_systems.json'.format(hostname, total_systems), 'w') as f:
f.write(json.dumps(result_dict)) f.write(json.dumps(result_dict))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment