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

updated scaling routine. fixed automatic hsotname, changed grid

parent a502a03d
Branches develop
No related tags found
No related merge requests found
...@@ -452,53 +452,6 @@ class Population(object): ...@@ -452,53 +452,6 @@ class Population(object):
else: else:
return out return out
def remove_file(self, file, verbose):
"""
Function to remove files but with verbosity
"""
if os.path.exists(file):
try:
if verbose > 0:
print("Removed {}".format())
os.remove(file)
except:
print("Error while deleting file {}".format(file))
raise FileNotFoundError
def clean_up_custom_logging(self, evol_type):
"""
Function to clean up the custom logging.
Has two types:
'single':
- removes the compiled shared library (which name is stored in grid_options['custom_logging_shared_library_file'])
- TODO: unloads/frees the memory allocated to that shared library (which is stored in grid_options['custom_logging_func_memaddr'])
- sets both to None
'multiple':
- TODO: make this and design this
"""
if evol_type == "single":
if self.grid_options["verbose"] > 0:
print("Cleaning up the custom logging stuff. type: single")
# TODO: Unset custom logging code
# TODO: Unset function memory adress
# print(self.grid_options["custom_logging_func_memaddr"])
# remove shared library files
if self.grid_options["custom_logging_shared_library_file"]:
self.remove_file(
self.grid_options["custom_logging_shared_library_file"],
self.grid_options["verbose"],
)
if evol_type == "population":
if self.grid_options["verbose"] > 0:
print("Cleaning up the custom logging stuffs. type: population")
# TODO: make sure that these also work. not fully sure if necessary tho. whether its a single file, or a dict of files/memaddresses
def evolve_population(self, parse_function, custom_arg_file=None): def evolve_population(self, parse_function, custom_arg_file=None):
""" """
The function that will evolve the population. This function contains many steps The function that will evolve the population. This function contains many steps
...@@ -554,7 +507,7 @@ class Population(object): ...@@ -554,7 +507,7 @@ class Population(object):
pass pass
# TODO: add call to function that cleans up the temp customlogging dir, and unloads the loaded libraries. # TODO: add call to function that cleans up the temp customlogging dir, and unloads the loaded libraries.
################################################### ###################################################
# Testing functions # Testing functions
################################################### ###################################################
...@@ -735,6 +688,55 @@ class Population(object): ...@@ -735,6 +688,55 @@ class Population(object):
# Unordered functions # Unordered functions
################################################### ###################################################
def remove_file(self, file, verbose):
"""
Function to remove files but with verbosity
"""
if os.path.exists(file):
try:
if verbose > 0:
print("Removed {}".format())
os.remove(file)
except:
print("Error while deleting file {}".format(file))
raise FileNotFoundError
def clean_up_custom_logging(self, evol_type):
"""
Function to clean up the custom logging.
Has two types:
'single':
- removes the compiled shared library (which name is stored in grid_options['custom_logging_shared_library_file'])
- TODO: unloads/frees the memory allocated to that shared library (which is stored in grid_options['custom_logging_func_memaddr'])
- sets both to None
'multiple':
- TODO: make this and design this
"""
if evol_type == "single":
if self.grid_options["verbose"] > 0:
print("Cleaning up the custom logging stuff. type: single")
# TODO: Unset custom logging code
# TODO: Unset function memory adress
# print(self.grid_options["custom_logging_func_memaddr"])
# remove shared library files
if self.grid_options["custom_logging_shared_library_file"]:
self.remove_file(
self.grid_options["custom_logging_shared_library_file"],
self.grid_options["verbose"],
)
if evol_type == "population":
if self.grid_options["verbose"] > 0:
print("Cleaning up the custom logging stuffs. type: population")
# TODO: make sure that these also work. not fully sure if necessary tho. whether its a single file, or a dict of files/memaddresses
def increment_probtot(self, prob): def increment_probtot(self, prob):
""" """
Function to add to the total probability Function to add to the total probability
......
(2, 225, 23.872895002365112, 17.51114845275879, 1.3632969343369403)
(2, 625, 76.88419461250305, 63.15470623970032, 1.2173945409656914)
(2, 100, 9.662783145904541, 5.593015670776367, 1.7276517204113695)
(2, 225, 22.48796582221985, 17.04386305809021, 1.319417185269245)
(2, 225, 22.703202962875366, 16.048972845077515, 1.4146203113452718)
...@@ -9,30 +9,36 @@ from binarycpython.utils.grid import Population ...@@ -9,30 +9,36 @@ from binarycpython.utils.grid import Population
from binarycpython.utils.functions import get_help_all, get_help, create_hdf5 from binarycpython.utils.functions import get_help_all, get_help, create_hdf5
# import argparse import argparse
# parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
# parser.add_argument(
# "amt_systems", help="the amount of systems",
# )
# parser.add_argument( parser.add_argument(
# "amt_nodes", help="the amount of nodes that are used for the multiprocessing", "resolution_M_1", help="Resolution in M_1",
# ) )
# parser.add_argument( parser.add_argument(
# "name_testcase", help="The name of the testcase (e.g. laptop, cluster etc)", "resolution_per", help="Resolution in period",
# ) )
parser.add_argument(
"amt_cores", help="The amount of nodes that are used for the multiprocessing",
)
parser.add_argument(
"name_testcase", help="The name of the testcase (e.g. laptop, cluster etc)",
)
# args = parser.parse_args()
# amt_systems = args.amt_systems args = parser.parse_args()
# amt_nodes = args.amt_nodes
# name_testcase = args.name_testcase
res_m_1 = int(args.resolution_M_1)
res_per = int(args.resolution_per)
AMT_CORES = int(args.amt_cores)
name_testcase = args.name_testcase
##############################################################################
## Quick script to get some output about which stars go supernova when. ## Quick script to get some output about which stars go supernova when.
def output_lines(output): def output_lines(output):
""" """
...@@ -72,25 +78,28 @@ def parse_function(self, output): ...@@ -72,25 +78,28 @@ def parse_function(self, output):
with open(outfilename, "a") as f: with open(outfilename, "a") as f:
f.write(seperator.join(values) + "\n") f.write(seperator.join(values) + "\n")
resolution = {'M_1': res_m_1, 'per': res_per}
total_systems = np.prod([el for el in resolution.values()])
# AMT_CORES = int(amt_cores)
test_pop = Population() test_pop = Population()
test_pop.set(verbose=1, test_pop.set(verbose=1,
amt_cores=4, amt_cores=AMT_CORES,
binary=1, binary=1,
) )
resolution = {'M_1': 10, 'per': 10}
test_pop.add_grid_variable( test_pop.add_grid_variable(
name="M_1", name="M_1",
longname="log primary mass", longname="log primary mass",
valuerange=[10, 100], valuerange=[1, 100],
resolution="{}".format(resolution['M_1']), resolution="{}".format(resolution['M_1']),
spacingfunc="const(10, 100, {})".format(resolution['M_1']), spacingfunc="const(1, 100, {})".format(resolution['M_1']),
precode="", precode="",
# precode="M_1=math.exp(lnm1)", # precode="M_1=math.exp(lnm1)",
probdist="flat(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",
parameter_name="M_1", parameter_name="M_1",
...@@ -111,14 +120,6 @@ test_pop.add_grid_variable( ...@@ -111,14 +120,6 @@ test_pop.add_grid_variable(
condition='self.grid_options["binary"]==1', condition='self.grid_options["binary"]==1',
) )
test_pop.set(verbose=1,
amt_cores=2,
binary=1,
)
total_systems = np.prod([el for el in resolution.values()])
AMT_CORES = 2
# Lin # Lin
total_lin_start = time.time() total_lin_start = time.time()
...@@ -140,4 +141,12 @@ total_mp_stop = time.time() ...@@ -140,4 +141,12 @@ total_mp_stop = time.time()
total_mp = total_mp_stop - total_mp_start total_mp = total_mp_stop - total_mp_start
print("MP ({} nodes) run with {} systems: {} of which {} spent on evolving the systems".format(AMT_CORES, total_systems, total_mp, evolve_mp_time)) print("MP ({} nodes) run with {} systems: {} of which {} spent on evolving the systems".format(AMT_CORES, total_systems, total_mp, evolve_mp_time))
print("The speed up by using MP is: {}".format(total_lin/total_mp)) speed_up = total_lin/total_mp
\ No newline at end of file print("The speed up by using MP is: {}".format(total_lin/total_mp))
# Write to file:
# amt_cores, amt_systems, total_time_lin, total_time_mp, speedup
with open("comparison_result_{}.dat".format(name_testcase), "a") as f:
res = (AMT_CORES, total_systems, total_lin, total_mp, speed_up)
f.write(str(res) + "\n")
\ No newline at end of file
#!/bin/bash
python evolve_population_comparing_with_multiprocessing.py 25 25 2 "${HOSTNAME}"
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