Skip to content
Snippets Groups Projects
Commit 84cc0a60 authored by Tim Jammer's avatar Tim Jammer
Browse files

Also added A CorrectMPICallFacory that generates correct MPI calls populated with default arguments

parent 6799e655
No related branches found
No related tags found
1 merge request!3more work on infrastructure II
...@@ -14,12 +14,23 @@ template = """ ...@@ -14,12 +14,23 @@ template = """
file_header="""#! /usr/bin/python3 file_header="""#! /usr/bin/python3
from collections import OrderedDict from collections import OrderedDict
from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory
from scripts.Infrastructure.MPICall import MPI_Call from scripts.Infrastructure.MPICall import MPI_Call
class MPI_Call_Factory: class MPI_Call_Factory:
""" """
correct_call_factory_header="""
class CorrectMPI_Call_Factory:
"""
template_correct = """
def @{FUNC_KEY}@(self):
correct_params = CorrectParameterFactory()
return MPI_Call_Factory().@{FUNC_KEY}@(@{PARAMS}@)
"""
def main(): def main():
# read in the "official" standards json to get all mpi functions and there params # read in the "official" standards json to get all mpi functions and there params
...@@ -31,19 +42,25 @@ def main(): ...@@ -31,19 +42,25 @@ def main():
class_str = file_header class_str = file_header
correct_class_str = correct_call_factory_header
version_dict = get_mpi_version_dict() version_dict = get_mpi_version_dict()
for key, api_spec in api_specs.items(): for key, api_spec in api_specs.items():
spec = api_specs[key] spec = api_specs[key]
name = spec['name'] name = spec['name']
dict_str = "[" dict_str = "["
correct_param_str = ""
i = 0 i = 0
for param in spec['parameters']: for param in spec['parameters']:
if 'c_parameter' not in param['suppress']: if 'c_parameter' not in param['suppress']:
dict_str = dict_str + "(\"" + param['name'] + "\", args[" + str(i) + "])," dict_str = dict_str + "(\"" + param['name'] + "\", args[" + str(i) + "]),"
correct_param_str = correct_param_str + "correct_params.get(\""+param['name']+"\"),"
i = i + 1 i = i + 1
pass pass
dict_str = dict_str + "]" dict_str = dict_str + "]"
correct_param_str=correct_param_str[:-1]# remove last ,
ver = "4.0" ver = "4.0"
# everyting not in dict is 4.0 # everyting not in dict is 4.0
...@@ -57,17 +74,13 @@ def main(): ...@@ -57,17 +74,13 @@ def main():
.replace("@{VERSION}@", ver)) .replace("@{VERSION}@", ver))
class_str = class_str+ function_def_str class_str = class_str+ function_def_str
with open(output_file,"w") as outfile: correct_function_def_str =(template_correct
outfile.write(class_str) .replace("@{FUNC_KEY}@", key)
.replace("@{PARAMS}@", correct_param_str))
correct_class_str=correct_class_str+ correct_function_def_str
# def mpi_send(self, *args):
# return MPI_Call("MPI_Send",
# OrderedDict([("BUFFER", args[0]), ("COUNT", args[1]), ("DATATYPE", args[2]), ("SRC", args[3]),
# ("TAG", args[4]), ("COMM", args[5])]),
# "1.0")
with open(output_file,"w") as outfile:
outfile.write(class_str+correct_class_str)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment