summaryrefslogtreecommitdiff
path: root/src/schedule
diff options
context:
space:
mode:
authorrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-06-11 19:37:40 +0000
committerrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-06-11 19:37:40 +0000
commit3d1f402c663ef0e6d76414f32e225fb0cb956e85 (patch)
treeca607dd81635577982b4042dfc83610228ac40d1 /src/schedule
parentebd9d3057b889f2fe224c7cd7a0c539aa33a4d5c (diff)
correctly detect circular schedule items
before this Cactus would not detect certain cyclic dependencies eg. ones where two scheduled functions are each scheduled after the other or where a function wants to be scheduled after itself. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4832 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/schedule')
-rw-r--r--src/schedule/ScheduleCreater.c30
-rw-r--r--src/schedule/ScheduleSorter.c9
2 files changed, 36 insertions, 3 deletions
diff --git a/src/schedule/ScheduleCreater.c b/src/schedule/ScheduleCreater.c
index ace2c9a7..87283600 100644
--- a/src/schedule/ScheduleCreater.c
+++ b/src/schedule/ScheduleCreater.c
@@ -790,7 +790,14 @@ static int ScheduleSortGroup(t_sched_group *group)
printf("\n");
#endif
- CCTKi_ScheduleAddRow(group->n_scheditems, array, order, item, thisorders);
+ errcode = CCTKi_ScheduleAddRow(group->n_scheditems, array, order, item, thisorders);
+ if(errcode)
+ {
+ CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, "Cactus",
+ "Adding item %s to group %s failed due to a circular dependency on %s.\n",
+ group->scheditems[item].name, group->name,
+ group->scheditems[-errcode-1].name ); /*NOTREACHED*/
+ }
/* Clear the array for the next item. */
for(i=0; i < group->n_scheditems; i++)
@@ -1047,9 +1054,30 @@ static int ScheduleSetupIfs(t_sched_item *item)
#ifdef TEST_SCHEDULECREATOR
+#include <stdarg.h>
+
#define func_x(x) \
int func_ ## x (void) { return printf("I'm func " #x "\n"); }
+int CCTK_VWarn(int level, int line, const char *file,
+ const char *thorn, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ fprintf(stdout, "WARNING[L%d,P0] (%s) in line %d of %s: ", level, thorn, line, file);
+ vfprintf(stdout, fmt, ap);
+ fputc('\n', stdout);
+
+ va_end(ap);
+
+ if(level == 0)
+ exit(1);
+
+ return 0;
+}
+
func_x(a)
func_x(b)
func_x(c)
diff --git a/src/schedule/ScheduleSorter.c b/src/schedule/ScheduleSorter.c
index edfb009c..e97874cb 100644
--- a/src/schedule/ScheduleSorter.c
+++ b/src/schedule/ScheduleSorter.c
@@ -166,7 +166,8 @@ int CCTKi_ScheduleSort(int size, signed char **array, int *order)
@returntype int
@returndesc
- 0 - success
+ 0 - success
+ <0 - -error_column
@endreturndesc
@@*/
int CCTKi_ScheduleAddRow(int size,
@@ -190,7 +191,11 @@ int CCTKi_ScheduleAddRow(int size,
{
if(thisorders[column])
{
- if(array[row][column] && array[row][column] != (signed char)thisorders[column]) retval--;
+ if(array[row][column] && array[row][column] != (signed char)thisorders[column])
+ {
+ retval = -(1+column);
+ break;
+ }
array[row][column] = (signed char)( thisorders[column]);
array[column][row] = (signed char)( -thisorders[column]);
}