summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhinder <hinder@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-01-31 19:18:30 +0000
committerhinder <hinder@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-01-31 19:18:30 +0000
commit100c3733a8d90eadc785becbd48494c7dfa67c73 (patch)
treea2212ae951d3132ea646b98329d799929ea8e8f2
parenta2309eb58c5107a4afdac9aaa2d044a7680242ce (diff)
Merge branch 'NewSchedule' into trunk
This provides support for specifying READS and WRITES clauses for each function scheduled in schedule.ccl. These list the variables which the scheduled function reads from or writes to. This supports future dependency-based scheduling. See https://docs.einsteintoolkit.org/et-docs/Adding_requirements_to_the_Cactus_scheduler for more information. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4788 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--lib/make/force-rebuild2
-rw-r--r--lib/sbin/CreateScheduleBindings.pl36
-rw-r--r--lib/sbin/ScheduleParser.pl35
-rw-r--r--src/include/cctk_Schedule.h11
-rw-r--r--src/include/cctki_ScheduleBindings.h4
-rw-r--r--src/main/ScheduleInterface.c165
6 files changed, 236 insertions, 17 deletions
diff --git a/lib/make/force-rebuild b/lib/make/force-rebuild
index d4247101..eb36a6f2 100644
--- a/lib/make/force-rebuild
+++ b/lib/make/force-rebuild
@@ -34,5 +34,7 @@
21 Nov 2005: Change names of auto-generated capability header files
08 Apr 2008: Add IF clause to scheduler
23 Dec 2010: Rename cctki_Capabilities.h to cctk_Capabilities.h
+12 Jan 2011: Add PROVIDES/REQUIRES clauses to scheduler
20 Jan 2011: Generate prototypes for scheduled functions
27 Oct 2011: Optimize CCTK_ARGUMENTS for grid functions in Fortran
+
diff --git a/lib/sbin/CreateScheduleBindings.pl b/lib/sbin/CreateScheduleBindings.pl
index 045b5d7a..095d49dc 100644
--- a/lib/sbin/CreateScheduleBindings.pl
+++ b/lib/sbin/CreateScheduleBindings.pl
@@ -499,8 +499,11 @@ sub ScheduleBlock
my($trigger_groups);
my($sync_groups);
my(@options);
+ my($tags);
my(@before_list);
my(@after_list);
+ my(@writes_list);
+ my(@reads_list);
my(@while_list);
my(@if_list);
@@ -532,6 +535,8 @@ sub ScheduleBlock
$rhinterface_db);
@options = split(/,/, $rhschedule_db->{"\U$thorn\E BLOCK_$block OPTIONS"});
+ $tags = $rhschedule_db->{"\U$thorn\E BLOCK_$block TAGS"};
+ $tags = '' if ! defined $tags;
@before_list = &ScheduleSelectRoutines($thorn, $implementation,
$rhschedule_db->{"\U$thorn\E BLOCK_$block BEFORE"},
@@ -541,6 +546,14 @@ sub ScheduleBlock
$rhschedule_db->{"\U$thorn\E BLOCK_$block AFTER"},
$rhschedule_db);
+ @writes_list = &ScheduleSelectRoutines($thorn, $implementation,
+ $rhschedule_db->{"\U$thorn\E BLOCK_$block WRITES"},
+ $rhschedule_db);
+
+ @reads_list = &ScheduleSelectRoutines($thorn, $implementation,
+ $rhschedule_db->{"\U$thorn\E BLOCK_$block READS"},
+ $rhschedule_db);
+
@while_list = &ScheduleSelectVars($thorn, $implementation,
$rhschedule_db->{"\U$thorn\E BLOCK_$block WHILE"},
$rhinterface_db);
@@ -648,16 +661,25 @@ sub ScheduleBlock
# $help .= 'IO methods to decide whether of not execution should happen.';
# &CST_error(0,$mess,$help,__LINE__,__FILE__);
# }
- $buffer .= $indent . scalar(@$sync_groups) . ", /* Number of SYNC groups */\n";
- $buffer .= $indent . scalar(@options) . ", /* Number of Options */\n";
- $buffer .= $indent . scalar(@before_list) . ", /* Number of BEFORE routines */\n";
- $buffer .= $indent . scalar(@after_list) . ", /* Number of AFTER routines */\n";
- $buffer .= $indent . scalar(@while_list) . ", /* Number of WHILE variables */\n";
- $buffer .= $indent . scalar(@if_list) . ", /* Number of IF variables */\n";
+ $buffer .= $indent . scalar(@$sync_groups) . ", /* Number of SYNC groups */\n";
+ $buffer .= $indent . scalar(@writes_list) . ", /* Number of WRITES clauses */\n";
+ $buffer .= $indent . scalar(@reads_list) . ", /* Number of READS clauses */\n";
+ $buffer .= $indent . scalar(@options) . ", /* Number of Options */\n";
+ $buffer .= $indent . scalar(@before_list) . ", /* Number of BEFORE routines */\n";
+ $buffer .= $indent . scalar(@after_list) . ", /* Number of AFTER routines */\n";
+ $buffer .= $indent . scalar(@while_list) . ", /* Number of WHILE variables */\n";
+ $buffer .= $indent . scalar(@if_list) . ", /* Number of IF variables */\n";
$buffer .= $indent . "cctkschedulei_tlevelarray /* Array of timelevel data for storage groups */";
foreach $item (@$mem_groups, @$comm_groups, @$trigger_groups, @$sync_groups,
- @options, @before_list, @after_list, @while_list, @if_list)
+ @writes_list, @reads_list, @options)
+ {
+ $buffer .= ",\n$indent\"$item\"";
+ }
+
+ $buffer .= ",\n$indent\"$tags\"";
+
+ foreach $item (@before_list, @after_list, @while_list, @if_list)
{
$buffer .= ",\n$indent\"$item\"";
}
diff --git a/lib/sbin/ScheduleParser.pl b/lib/sbin/ScheduleParser.pl
index 9fdff5f5..7670b19d 100644
--- a/lib/sbin/ScheduleParser.pl
+++ b/lib/sbin/ScheduleParser.pl
@@ -113,7 +113,8 @@ sub parse_schedule_ccl
my($n_statements);
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list, $if_list);
+ $options, $tags, $before_list, $after_list,
+ $writes_list, $reads_list, $while_list, $if_list);
my($groups);
$buffer = "";
@@ -127,8 +128,9 @@ sub parse_schedule_ccl
($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list, $if_list)
- = &ParseScheduleBlock($thorn,$line_number, @data);
+ $options, $tags, $before_list, $after_list,
+ $writes_list, $reads_list, $while_list, $if_list) =
+ &ParseScheduleBlock($thorn,$line_number, @data);
$schedule_db{"\U$thorn\E BLOCK_$n_blocks NAME"} = $name;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AS"} = $as;
@@ -141,8 +143,11 @@ sub parse_schedule_ccl
$schedule_db{"\U$thorn\E BLOCK_$n_blocks TRIG"} = $trigger_groups;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks SYNC"} = $sync_groups;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks OPTIONS"} = $options;
+ $schedule_db{"\U$thorn\E BLOCK_$n_blocks TAGS"} = $tags;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks BEFORE"} = $before_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AFTER"} = $after_list;
+ $schedule_db{"\U$thorn\E BLOCK_$n_blocks WRITES"} = $writes_list;
+ $schedule_db{"\U$thorn\E BLOCK_$n_blocks READS"} = $reads_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks WHILE"} = $while_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks IF"} = $if_list;
@@ -196,11 +201,14 @@ sub ParseScheduleBlock
my($thorn,$line_number, @data) = @_;
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list, $if_list);
+ $options, $tags, $before_list, $after_list,
+ $writes_list, $reads_list, $while_list, $if_list);
my(@fields);
my($field);
my(@before_list) = ();
my(@after_list) = ();
+ my(@writes_list) = ();
+ my(@reads_list) = ();
my(@while_list) = ();
my(@if_list) = ();
my(@mem_groups) = ();
@@ -208,6 +216,7 @@ sub ParseScheduleBlock
my(@trigger_groups) = ();
my(@sync_groups) = ();
my(@options) = ();
+ my(@tags) = ();
my($keyword) = "";
my(@current_sched_list) = ();
@@ -467,10 +476,22 @@ sub ParseScheduleBlock
{
push(@sync_groups, split(/\s+|\s*,\s*/, $1));
}
+ elsif($data[$line_number] =~ m/^\s*WRITES\s*:\s*(.*)$/i)
+ {
+ push(@writes_list, split(/\s+|\s*,\s*/, $1));
+ }
+ elsif($data[$line_number] =~ m/^\s*READS\s*:\s*(.*)$/i)
+ {
+ push(@reads_list, split(/\s+|\s*,\s*/, $1));
+ }
elsif($data[$line_number] =~ m/^\s*OPTI[^:]*:\s*(.*)$/i)
{
push(@options, split(/\s+|\s*,\s*/, $1));
}
+ elsif($data[$line_number] =~ m/^\s*TAGS[^:]*:\s*(.*)$/i)
+ {
+ push(@tags, $1);
+ }
elsif($data[$line_number] =~ m/^\s*LANG[^:]*:\s*(.*)$/i)
{
if($language ne "")
@@ -518,8 +539,11 @@ sub ParseScheduleBlock
$trigger_groups = join(",", @trigger_groups);
$sync_groups = join(",", @sync_groups);
$options = join(",", @options);
+ $tags = join(" ", @tags);
$before_list = join(",", @before_list);
$after_list = join(",", @after_list);
+ $writes_list = join(",", @writes_list);
+ $reads_list = join(",", @reads_list);
$while_list = join(",", @while_list);
$if_list = join(",", @if_list);
@@ -527,7 +551,8 @@ sub ParseScheduleBlock
return ($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list, $if_list);
+ $options, $tags, $before_list, $after_list,
+ $writes_list, $reads_list, $while_list, $if_list);
}
diff --git a/src/include/cctk_Schedule.h b/src/include/cctk_Schedule.h
index b9ce40e6..5a2da202 100644
--- a/src/include/cctk_Schedule.h
+++ b/src/include/cctk_Schedule.h
@@ -46,10 +46,19 @@ typedef struct
int loop_singlemap;
int loop_local;
+ int tags;
+
/* The last items should be considered volatile and may not stay here */
int n_TriggerGroups;
int *TriggerGroups;
+
+#define CACTUS_HAS_READS_CLAUSES
+ int n_WritesClauses;
+ const char **WritesClauses;
+ int n_ReadsClauses;
+ const char **ReadsClauses;
+
char *where;
char *routine;
char *thorn;
@@ -88,6 +97,8 @@ int CCTK_ScheduleFunction(void *function,
int n_trigger_groups,
int n_before,
int n_after,
+ int n_writes,
+ int n_reads,
int n_while,
int n_if,
...);
diff --git a/src/include/cctki_ScheduleBindings.h b/src/include/cctki_ScheduleBindings.h
index a87fb301..3495d11b 100644
--- a/src/include/cctki_ScheduleBindings.h
+++ b/src/include/cctki_ScheduleBindings.h
@@ -29,6 +29,8 @@ int CCTKi_ScheduleFunction(void *function,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
int n_before,
int n_after,
@@ -47,6 +49,8 @@ int CCTKi_ScheduleGroup(const char *realname,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
int n_before,
int n_after,
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index b471eea7..08309203 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -123,6 +123,8 @@ static t_attribute *CreateAttribute(const char *where,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
const int *timelevels,
va_list *ap);
@@ -131,6 +133,9 @@ static int ParseOptionList(int n_items,
t_attribute *attribute,
va_list *ap);
+static int ParseTagsTable(t_attribute *attribute,
+ va_list *ap);
+
static int InitialiseOptionList(t_attribute *attribute);
static int ParseOption(t_attribute *attribute,
@@ -145,6 +150,7 @@ static t_sched_modifier *CreateModifiers(int n_before,
int ValidateModifiers(t_sched_modifier *modifier);
static int CreateGroupIndexList(int n_items, int *array, va_list *ap);
+static int CreateStringList(int n_items, const char **array, va_list *ap);
static t_sched_modifier *CreateTypedModifier(t_sched_modifier *modifier,
const char *type,
int n_items,
@@ -371,6 +377,16 @@ int CCTK_CallFunction(void *function,
@vtype int
@vio in
@endvar
+ @var n_writes
+ @vdesc Number of writes clauses
+ @vtype int
+ @vio in
+ @endvar
+ @var n_reads
+ @vdesc Number of reads clauses
+ @vtype int
+ @vio in
+ @endvar
@var n_options
@vdesc Number of options for this schedule block
@vtype int
@@ -423,6 +439,8 @@ int CCTKi_ScheduleFunction(void *function,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
int n_before,
int n_after,
@@ -441,7 +459,8 @@ int CCTKi_ScheduleFunction(void *function,
attribute = CreateAttribute(where,name,description, language, thorn, implementation,
n_mem_groups, n_comm_groups, n_trigger_groups,
- n_sync_groups, n_options, timelevels, &ap);
+ n_sync_groups, n_writes, n_reads,
+ n_options, timelevels, &ap);
modifier = CreateModifiers(n_before, n_after, n_while, n_if, &ap);
va_end(ap);
@@ -534,6 +553,16 @@ int CCTKi_ScheduleFunction(void *function,
@vtype int
@vio in
@endvar
+ @var n_writes
+ @vdesc Number of writes clauses
+ @vtype int
+ @vio in
+ @endvar
+ @var n_reads
+ @vdesc Number of reads clauses
+ @vtype int
+ @vio in
+ @endvar
@var n_options
@vdesc Number of options for this schedule block
@vtype int
@@ -584,6 +613,8 @@ int CCTKi_ScheduleGroup(const char *realname,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
int n_before,
int n_after,
@@ -602,7 +633,8 @@ int CCTKi_ScheduleGroup(const char *realname,
attribute = CreateAttribute(where,name,description, NULL, thorn, implementation,
n_mem_groups, n_comm_groups, n_trigger_groups,
- n_sync_groups, n_options, timelevels, &ap);
+ n_sync_groups, n_writes, n_reads,
+ n_options, timelevels, &ap);
modifier = CreateModifiers(n_before, n_after, n_while, n_if, &ap);
va_end(ap);
@@ -610,6 +642,7 @@ int CCTKi_ScheduleGroup(const char *realname,
ValidateModifiers(modifier);
if(attribute && (modifier || (n_before == 0 && n_after == 0 &&
+ n_writes == 0 && n_reads == 0 &&
n_while == 0 && n_if == 0)))
{
retcode = CCTKi_DoScheduleGroup(where, name, realname, modifier, (void *)attribute);
@@ -1338,6 +1371,16 @@ static int ScheduleTraverse(const char *where,
@vtype int
@vio in
@endvar
+ @var n_writes
+ @vdesc Number of writes clauses
+ @vtype int
+ @vio in
+ @endvar
+ @var n_reads
+ @vdesc Number of reads clauses
+ @vtype int
+ @vio in
+ @endvar
@var n_options
@vdesc Number of options for this schedule block
@vtype int
@@ -1369,6 +1412,8 @@ static t_attribute *CreateAttribute(const char *where,
int n_comm_groups,
int n_trigger_groups,
int n_sync_groups,
+ int n_writes,
+ int n_reads,
int n_options,
const int *timelevels,
va_list *ap)
@@ -1399,6 +1444,14 @@ static t_attribute *CreateAttribute(const char *where,
{
this->FunctionData.SyncGroups = malloc(n_sync_groups*sizeof(int));
}
+ if (n_writes > 0)
+ {
+ this->FunctionData.WritesClauses = malloc(n_writes*sizeof(char*));
+ }
+ if (n_reads > 0)
+ {
+ this->FunctionData.ReadsClauses = malloc(n_reads*sizeof(char*));
+ }
if (n_comm_groups > 0)
{
this->comm_groups = malloc(n_comm_groups*sizeof(int));
@@ -1415,7 +1468,9 @@ static t_attribute *CreateAttribute(const char *where,
(this->StorageOnEntry || n_mem_groups==0) &&
(this->comm_groups || n_comm_groups==0) &&
(this->FunctionData.TriggerGroups || n_trigger_groups==0) &&
- (this->FunctionData.SyncGroups || n_sync_groups==0))
+ (this->FunctionData.SyncGroups || n_sync_groups==0) &&
+ (this->FunctionData.WritesClauses || n_writes==0) &&
+ (this->FunctionData.ReadsClauses || n_reads==0))
{
strcpy(this->FunctionData.where,where);
strcpy(this->FunctionData.routine,name);
@@ -1439,6 +1494,8 @@ static t_attribute *CreateAttribute(const char *where,
CreateGroupIndexList(n_comm_groups, this->comm_groups, ap);
CreateGroupIndexList(n_trigger_groups, this->FunctionData.TriggerGroups, ap);
CreateGroupIndexList(n_sync_groups, this->FunctionData.SyncGroups, ap);
+ CreateStringList (n_writes, this->FunctionData.WritesClauses, ap);
+ CreateStringList (n_reads, this->FunctionData.ReadsClauses, ap);
for(i=0; i< n_mem_groups; i++)
{
@@ -1450,10 +1507,15 @@ static t_attribute *CreateAttribute(const char *where,
InitialiseOptionList(this);
ParseOptionList(n_options, this, ap);
+ /* Check the tags */
+ ParseTagsTable(this, ap);
+
this->n_mem_groups = n_mem_groups;
this->n_comm_groups = n_comm_groups;
this->FunctionData.n_TriggerGroups = n_trigger_groups;
this->FunctionData.n_SyncGroups = n_sync_groups;
+ this->FunctionData.n_WritesClauses = n_writes;
+ this->FunctionData.n_ReadsClauses = n_reads;
this->timers = NULL;
}
@@ -1465,6 +1527,8 @@ static t_attribute *CreateAttribute(const char *where,
free(this->comm_groups);
free(this->FunctionData.TriggerGroups);
free(this->FunctionData.SyncGroups);
+ free(this->FunctionData.WritesClauses);
+ free(this->FunctionData.ReadsClauses);
free(this);
this = NULL;
}
@@ -1645,6 +1709,53 @@ static int CreateGroupIndexList(int n_items, int *array, va_list *ap)
}
+/*@@
+ @routine CreateStringList
+ @date 2007-05-24
+ @author Erik Schnetter
+ @desc
+ Gets the next n_items group names from the variable argument list
+ and converts them to strings.
+ @enddesc
+ @calls
+
+ @var n_items
+ @vdesc number of items on the list
+ @vtype int
+ @vio in
+ @endvar
+ @var array
+ @vdesc array of strings
+ @vtype char **
+ @vio out
+ @endvar
+ @var ap
+ @vdesc argument list
+ @vtype va_list of const char *
+ @vio inout
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 - success
+ @endreturndesc
+@@*/
+static int CreateStringList(int n_items, const char **array, va_list *ap)
+{
+ int i;
+ const char *item;
+
+ for(i=0; i < n_items; i++)
+ {
+ item = va_arg(*ap, const char *);
+
+ array[i] = strdup(item);
+ }
+
+ return 0;
+}
+
+
/*@@
@routine ParseOptionList
@date Thu Jan 27 20:26:42 2000
@@ -1830,6 +1941,50 @@ static int ParseOption(t_attribute *attribute,
return 0;
}
+
+ /*@@
+ @routine ParseTagsTable
+ @date 2006-08-03
+ @author Erik Schnetter
+ @desc
+ Extract the tags table in a schedule group definition.
+ @enddesc
+ @calls
+
+ @var attribute
+ @vdesc attribute list
+ @vtype t_attribute *
+ @vio inout
+ @endvar
+ @var ap
+ @vdesc argument list
+ @vtype va_list of const char *
+ @vio inout
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 - success
+ @endreturndesc
+@@*/
+static int ParseTagsTable(t_attribute *attribute,
+ va_list *ap)
+{
+ const char *item;
+ int table;
+
+ item = va_arg(*ap, const char *);
+ table = Util_TableCreateFromString (item);
+ if (table < 0)
+ {
+ return table;
+ }
+ attribute->FunctionData.tags = table;
+
+ return 0;
+}
+
+
/*@@
@routine CreateTypedModifier
@date Fri Sep 17 21:50:59 1999
@@ -1968,7 +2123,7 @@ static cFunctionType TranslateFunctionType(const char *where)
@returntype int
@returndesc
- return of DoScheduleTravers or
+ return code of DoScheduleTraverse or
0 - where is NULL
@endreturndesc
@@*/
@@ -2026,7 +2181,7 @@ static int SchedulePrint(const char *where)
@returntype int
@returndesc
- return of DoScheduleTravers or
+ return code of DoScheduleTraverse or
0 - where is NULL
@endreturndesc
@@*/