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

Refactoring: split file; Added ALL Mpi callsto MPICallFactory.py; fixed wrong filename

parent f63cf243
No related branches found
No related tags found
1 merge request!2more work on infrastructure
...@@ -6,7 +6,7 @@ from scripts.Infrastructure.Template import InstructionBlock ...@@ -6,7 +6,7 @@ from scripts.Infrastructure.Template import InstructionBlock
class MPI_Call_Factory: class MPI_Call_Factory:
# one could generate the MPI Factory from the Standards JSON
def mpi_send(self, *args): def mpi_send(self, *args):
return MPI_Call("MPI_Send", return MPI_Call("MPI_Send",
OrderedDict([("BUFFER", args[0]), ("COUNT", args[1]), ("DATATYPE", args[2]), ("SRC", args[3]), OrderedDict([("BUFFER", args[0]), ("COUNT", args[1]), ("DATATYPE", args[2]), ("SRC", args[3]),
......
# THIS FILE IS NOT FOR PUBLICATION
# it is only used to generate the MPICallFactory code
import json
from scripts.Infrastructure.MPIAPIInfo.MPIAPIParameters import get_mpi_version_dict
template = """
def @{FUNC_KEY}@(self, *args):
return MPI_Call("@{FUNC_NAME}@", OrderedDict(@{PARAM_DICT}@), "@{VERSION}@")
"""
file_header="""#! /usr/bin/python3
from collections import OrderedDict
from scripts.Infrastructure.MPICall import MPI_Call
class MPI_Call_Factory:
"""
def main():
# read in the "official" standards json to get all mpi functions and there params
mpi_api_json_file = "scripts/Infrastructure/MPIAPIInfo/MPI_api.json"
output_file = "scripts/Infrastructure/MPICallFactory.py"
with open(mpi_api_json_file, "r") as file:
api_specs = json.load(file)
class_str = file_header
version_dict = get_mpi_version_dict()
for key, api_spec in api_specs.items():
spec = api_specs[key]
name = spec['name']
dict_str = "["
i = 0
for param in spec['parameters']:
if 'c_parameter' not in param['suppress']:
dict_str = dict_str + "(\"" + param['name'] + "\", args[" + str(i) + "]),"
i = i + 1
pass
dict_str = dict_str + "]"
ver = "4.0"
# everyting not in dict is 4.0
if (name in version_dict):
ver = version_dict[name]
function_def_str = (template.replace("@{FUNC_KEY}@", key)
.replace("@{FUNC_NAME}@", name)
.replace("@{PARAM_DICT}@", dict_str)
.replace("@{VERSION}@", ver))
class_str = class_str+ function_def_str
with open(output_file,"w") as outfile:
outfile.write(class_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")
if __name__ == "__main__":
main()
This diff is collapsed.
This diff is collapsed.
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
from scripts.Infrastructure.ErrorGenerator import ErrorGenerator from scripts.Infrastructure.ErrorGenerator import ErrorGenerator
from scripts.Infrastructure.InstructionBlock import InstructionBlock from scripts.Infrastructure.InstructionBlock import InstructionBlock
from scripts.Infrastructure.MPICallFactroy import Correct_Parameter, MPI_Call_Factory, get_matching_recv from scripts.Infrastructure.MPICallFactory import MPI_Call_Factory
from scripts.Infrastructure.CorrectParameter import Correct_Parameter,get_matching_recv
from scripts.Infrastructure.Template import TemplateManager from scripts.Infrastructure.Template import TemplateManager
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment