From 5379a7fc3d237f656394af1d780509debd813fac Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Wed, 25 May 2016 17:19:01 +0100 Subject: [PATCH] Add schedule implementation --- sparsetiling/src/schedule.cpp | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sparsetiling/src/schedule.cpp diff --git a/sparsetiling/src/schedule.cpp b/sparsetiling/src/schedule.cpp new file mode 100644 index 0000000..63c5d98 --- /dev/null +++ b/sparsetiling/src/schedule.cpp @@ -0,0 +1,63 @@ +/* + * schedule.cpp + * + * Implementation of a schedule + */ + +#include + +#include "schedule.h" + +schedule_t* schedule_init (std::string name, int itSetSize, int* iter2tile, + int* iter2color, direction_t direction) +{ + schedule_t* schedule = new schedule_t; + + schedule->name = name; + schedule->itSetSize = itSetSize; + schedule->iter2tile = iter2tile; + schedule->iter2color = iter2color; + schedule->direction = direction; + + return schedule; +} + +schedule_t* schedule_cpy (schedule_t* toCopy) +{ + schedule_t* schedule = new schedule_t; + + schedule->name = toCopy->name; + schedule->itSetSize = toCopy->itSetSize; + schedule->iter2tile = new int[toCopy->itSetSize]; + schedule->iter2color = new int[toCopy->itSetSize]; + schedule->direction = toCopy->direction; + + memcpy (schedule->iter2tile, toCopy->iter2tile, sizeof(int)*toCopy->itSetSize); + memcpy (schedule->iter2color, toCopy->iter2color, sizeof(int)*toCopy->itSetSize); + + return schedule; +} + +void schedule_free (schedule_t* schedule) +{ + if (! schedule) { + return; + } + delete[] schedule->iter2tile; + delete[] schedule->iter2color; + delete schedule; +} + +projection_t* projection_init() +{ + return new projection_t (&schedule_cmp); +} + +void projection_free (projection_t* projection) +{ + projection_t::iterator it, end; + for (it = projection->begin(), end = projection->end(); it != end; it++) { + schedule_free(*it); + } + delete projection; +}