Skip to content
Snippets Groups Projects
Commit 4a570fb0 authored by Nordine Feddal's avatar Nordine Feddal
Browse files

added main function and all steps inside vector

parent a85eee3f
No related merge requests found
......@@ -26,7 +26,7 @@ def parse_tasks(args):
with open(args.gpu_tasks, "r") as inFile, open(args.output_file, "a") as outFile:
outFile.write("#include <stdio.h>\n"
"#include <string>\n"
"#include \"step_struct.hpp\"\n"
"#include \"steps_struct.hpp\"\n"
"#include \"{kernel_file}\"\n".format(kernel_file=args.kernel_declaration)
)
......@@ -99,7 +99,6 @@ def parse_sched_order(args):
outFile.write("#define __GPUSCHED_STEPS__HPP\n")
outFile.write("#include <vector>\n")
outFile.write(GPUSchedStepParams.dump_struct())
outFile.write(GPUSchedStepParams.dump_global_vector())
for step in schedOrder:
step = step.rstrip(' ').lstrip(' ').rstrip('\n')
# If to differentiate step with multiple kernels call and those with only one
......@@ -112,8 +111,9 @@ def parse_sched_order(args):
outFile.write(currGpuSchedStep.dump_str())
step_no += 1
outFile.write(GPUSchedStepParams.dump_global_vector())
outFile.write("#endif")
print(GPUSchedStepParams.dump_struct())
"""
Retrieve a task in list_gpu_tasks_object by its id.
......
......@@ -26,28 +26,40 @@ class GPUSchedStepParams:
return dump
def dump_global_vector():
dump = "static std::vector<{struct_name}>& gpusched_steps()\n{{\n".format(struct_name=GPUSchedStepParams.STRUCT_NAME)
dump = "static std::vector<{struct_name}>& get_gpusched_steps()\n{{\n".format(struct_name=GPUSchedStepParams.STRUCT_NAME)
dump += "\tstatic std::vector<{struct_name}> steps;\n".format(struct_name=GPUSchedStepParams.STRUCT_NAME)
dump += "\t// Add all steps in vector\n"
for i in range(0, GPUSchedResultStep.NUMBER_STEP+1):
dump += "\tsteps.push_back(step_{no});\n".format(no=i)
dump += "\treturn steps;\n}\n\n"
return dump
class GPUSchedResultStep:
STRUCT_STEP = "gpusched_step_t step_{no} = {{\n";
TRACK_MAX_JOBS = 0 # tracker to know how much stream is required for this schedule order
NUMBER_STEP = 0
def __init__(self, number_kernels, list_jobs, step_no):
if GPUSchedResultStep.TRACK_MAX_JOBS < number_kernels:
GPUSchedResultStep.TRACK_MAX_JOBS = number_kernels
GPUSchedResultStep.NUMBER_STEP = step_no
self.number_kernels = number_kernels # number of kernels to execute for this step
self.list_jobs = list_jobs # list of jobs
self.step_no = step_no
# differentiate case when we only have one kernel we don't want to join with comma
if number_kernels != 1:
self.str_list_jobs = ','.join(self.list_jobs)
else:
self.str_list_jobs = list_jobs
self.step_no = step_no
self.dump_str()
def dump_str(self):
print("Start a GPUSCHED step dump")
dump = GPUSchedResultStep.STRUCT_STEP.format(no=self.step_no)
dump += GPUSchedStepParams.ARRAY_IMPL.format(SIZE=self.number_kernels, list_jobs = self.str_list_jobs)
......
......@@ -17,6 +17,15 @@ def check_file_exist(args):
else:
return True
def write_main(args):
with open(args.output_file, "a") as outFile:
outFile.write("int main(int argc, char **argv){\n"
"\tauto steps = get_gpusched_steps();\n"
"\tprintf(\"Start the execution of GPUSCHED order\");\n"
"\tprintf(\"There is %d steps to execute\", steps.size());\n"
"}"
)
def main():
parser = argparse.ArgumentParser(description="Generate a cu file that impelement the schedule graph generated by GPUSCHED")
parser.add_argument('-t', '--gpu_tasks', type=str, help='Input file containing GPU Tasks information')
......@@ -38,6 +47,7 @@ def main():
parse_tasks(args)
parse_jobs(args)
parse_sched_order(args)
write_main(args)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment