Skip to content

Commit

Permalink
Merge pull request #73 from GraphIt-DSL/ajaybr
Browse files Browse the repository at this point in the history
Separated the user_schedule into separate function to avoid recompila…
  • Loading branch information
yunmingzhang17 authored Sep 5, 2018
2 parents 1510785 + 0b1a77b commit bfa0264
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ file(GLOB_RECURSE HEADER_FILES include/*.h)

file(GLOB_RECURSE SOURCE_FILES include/*.h include/graphit/midend/*.h src/*.cpp src/frontend/*.cpp src/midend/*.cpp src/backend/*.cpp src/utils/*.cpp src/utils/*.h include/utils/*.h)
add_executable(graphitc ${SOURCE_FILES})
target_compile_definitions(graphitc PRIVATE USE_DEFAULT_SCHEDULE)

# build a front end library used for unit testing
file(GLOB_RECURSE LIB_SOURCE_FILES include/*.h src/frontend/*.cpp src/midend/*.cpp src/backend/*.cpp src/utils/*.cpp)
file(GLOB_RECURSE LIB_SOURCE_FILES include/*.h src/frontend/*.cpp src/midend/*.cpp src/backend/*.cpp src/utils/*.cpp src/main.cpp)

add_library(graphitlib ${HEADER_FILES} ${LIB_SOURCE_FILES})

Expand Down Expand Up @@ -53,4 +54,4 @@ configure_file(src/main.cpp ${CMAKE_BINARY_DIR}/bin/main.cpp COPYONLY)

add_executable(bfs_verifier ./test/verifiers/bfs_verifier.cpp)
add_executable(sssp_verifier ./test/verifiers/sssp_verifier.cpp)
add_executable(cc_verifier ./test/verifiers/cc_verifier.cpp)
add_executable(cc_verifier ./test/verifiers/cc_verifier.cpp)
22 changes: 9 additions & 13 deletions src/graphitc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def parseArgs():
output_file_name = args['output_file_name']
runtime_include_path = args['runtime_include_path']
graphitlib_path = args['graphitlib_path']
compile_template_file = "main.cpp"

#check if user supplied a separate algorithm file from the schedule file
supplied_separate_algo_file = False
Expand All @@ -31,6 +30,7 @@ def parseArgs():
else:
# use the input_file for both the algorithm and schedule
algo_file_name = 'algo.gt'

compile_file_name = 'compile.cpp'


Expand All @@ -56,21 +56,17 @@ def parseArgs():
if not supplied_separate_algo_file:
algo_file.close();

# generate a file compile.cpp for compiling the algo.gt file
with open(compile_template_file) as f:
content = f.readlines()

# copy over the default file template
# generate the schedule file schedule.cpp
compile_file = open(compile_file_name, 'w')

for line in content:
if "insert schedule here" in line:
#insert the schedule commands here
for schedule_cmd in schedule_cmd_list:
compile_file.write(schedule_cmd)
compile_file.write("#include <graphit/frontend/high_level_schedule.h>\n")
compile_file.write("namespace graphit {\n")
compile_file.write("void user_defined_schedule (graphit::fir::high_level_schedule::ProgramScheduleNode::Ptr program) {\n")
for schedule_cmd in schedule_cmd_list:
compile_file.write(schedule_cmd)
compile_file.write("}\n")
compile_file.write("}")

else:
compile_file.write(line)

compile_file.close();

Expand Down
11 changes: 10 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

using namespace graphit;


namespace graphit {
extern void user_defined_schedule (fir::high_level_schedule::ProgramScheduleNode::Ptr program);
}

int main(int argc, char* argv[]) {
// Set up various data structures
CLBase cli(argc, argv, "graphit compiler");
Expand Down Expand Up @@ -41,7 +46,11 @@ int main(int argc, char* argv[]) {

fir::high_level_schedule::ProgramScheduleNode::Ptr program
= std::make_shared<fir::high_level_schedule::ProgramScheduleNode>(context);
//insert schedule here

#ifndef USE_DEFAULT_SCHEDULE
//Call the user provided schedule for the algorithm
user_defined_schedule(program);
#endif

graphit::Midend* me = new graphit::Midend(context, program->getSchedule());
me->emitMIR(mir_context);
Expand Down

0 comments on commit bfa0264

Please sign in to comment.