Commit 3086d16e authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add inter-partition connections

parent c4a28388
......@@ -343,7 +343,7 @@ package body TASTE.AADL_Parser is
Dist.Function_Name & "_" & Dist.Interface_Name;
Port_Name : constant Unbounded_String := RI.Name;
-- Remote_Thread_Name & "_" & Dist.Interface_Name;
New_P : constant Port :=
New_P : constant Thread_Port :=
(Name => Port_Name,
Remote_Thread => Remote_Thread_Name,
Remote_PI => Dist.Interface_Name,
......@@ -484,10 +484,89 @@ package body TASTE.AADL_Parser is
end;
<<Continue>>
end loop;
-- Find and set protected blocks calling threads
for Node of CV.Nodes loop
for Partition of Node.Partitions loop
-- Find and set protected blocks calling threads
Set_Calling_Threads (Partition);
-- Define ports at partition (process) level
-- (ports are for all interfaces of a function are not located
-- in the same partition of the system)
for T of Partition.Threads loop
-- Check each Remote PI of the entry port of the thread
for Remote of T.PI.Remote_Interfaces loop
declare
Node : constant Option_Node.Option :=
CV.Deployment.Find_Node
(To_String (Remote.Function_Name));
Part : Option_Partition.Option;
-- Optional type of the parameter:
Sort : constant Unbounded_String :=
(if not T.PI.Params.Is_Empty
then T.PI.Params.First_Element.Sort
else US (""));
begin
if Node.Has_Value then
Part :=
Node.Unsafe_Just.Find_Partition
(To_String (Remote.Function_Name));
if Part.Has_Value
and then Part.Unsafe_Just.Name
/= Partition.Deployment_Partition.Name
then
-- shouldn't we check for presence first in case
-- there are multiple callers?
Partition.In_Ports.Insert
(Key => To_String (T.Entry_Port_Name),
New_Item => (Port_Name => T.Entry_Port_Name,
Thread_Name => T.Name,
Type_Name => Sort,
Remote_Partition_Name
=> Part.Unsafe_Just.Name));
end if;
else
Put_Error ("This should never happen.");
end if;
end;
end loop;
-- Do the same for output ports
for Out_Port of T.Output_Ports loop
for Remote of Out_Port.RI.Remote_Interfaces loop
declare
Node : constant Option_Node.Option :=
CV.Deployment.Find_Node
(To_String (Remote.Function_Name));
Part : Option_Partition.Option;
-- Optional type of the parameter:
Sort : constant Unbounded_String :=
(if not T.PI.Params.Is_Empty
then T.PI.Params.First_Element.Sort
else US (""));
begin
if Node.Has_Value then
Part := Node.Unsafe_Just.Find_Partition
(To_String (Remote.Function_Name));
if Part.Has_Value and then Part.Unsafe_Just.Name
/= Partition.Deployment_Partition.Name
then
Partition.Out_Ports.Insert
(Key => To_String (Out_Port.RI.Name),
New_Item => (Port_Name => Out_Port.RI.Name,
Thread_Name => T.Name,
Type_Name => Sort,
Remote_Partition_Name
=> Part.Unsafe_Just.Name));
end if;
else
Put_Error ("This should never happen.");
end if;
end;
end loop;
end loop;
end loop;
end loop;
end loop;
......
......@@ -216,10 +216,17 @@ package body TASTE.Concurrency_View is
Blocks : Unbounded_String;
Partition_Assoc : Translate_Set;
-- Connections between threads:
Thread_Src_Name : Vector_Tag;
Thread_Src_Name,
Thread_Src_Port : Vector_Tag;
Thread_Dst_Name : Vector_Tag;
Thread_Dst_Name,
Thread_Dst_Port : Vector_Tag;
Input_Port_Names,
Input_Port_Type_Name,
Input_Port_Thread_Name : Vector_Tag;
Output_Port_Names,
Output_Port_Type_Name,
Output_Port_Thread_Name : Vector_Tag;
-- Optionally generate partition code in separate files
-- (if filepart.tmplt is present and contains a filename)
File_Id : constant String := Path & "/filepart.tmplt";
......@@ -231,6 +238,21 @@ package body TASTE.Concurrency_View is
else "");
Part_Content : Unbounded_String;
begin
for Each of Partition.In_Ports loop
Input_Port_Names := Input_Port_Names & Each.Port_Name;
Input_Port_Type_Name := Input_Port_Type_Name
& Each.Type_Name;
Input_Port_Thread_Name :=
Input_Port_Thread_Name & Each.Thread_Name;
end loop;
for Each of Partition.Out_Ports loop
Output_Port_Names := Output_Port_Names & Each.Port_Name;
Output_Port_Type_Name := Output_Port_Type_Name
& Each.Type_Name;
Output_Port_Thread_Name :=
Output_Port_Thread_Name & Each.Thread_Name;
end loop;
for T of Partition.Threads loop
declare
-- There is no "&" operator for Translate sets...
......@@ -266,13 +288,19 @@ package body TASTE.Concurrency_View is
Thread_Names := Thread_Names & Name;
All_Thread_Names := All_Thread_Names & Name;
for P of T.Output_Ports loop
Thread_Src_Name := Thread_Src_Name & Name;
Thread_Src_Port := Thread_Src_Port
& To_String (P.Name);
Thread_Dst_Name := Thread_Dst_Name
& To_String (P.Remote_Thread);
Thread_Dst_Port := Thread_Dst_Port
& To_String (P.Remote_PI);
for Part_Threads of Partition.Threads loop
-- Create partition ports only when source and
-- destination are in the same partition
if P.Remote_Thread = Part_Threads.Name then
Thread_Src_Name := Thread_Src_Name & Name;
Thread_Src_Port := Thread_Src_Port
& To_String (P.Name);
Thread_Dst_Name := Thread_Dst_Name
& To_String (P.Remote_Thread);
Thread_Dst_Port := Thread_Dst_Port
& To_String (P.Remote_PI);
end if;
end loop;
end loop;
-- Save the content of the thread in a file
-- (if required at template folder level)
......@@ -359,16 +387,22 @@ package body TASTE.Concurrency_View is
-- Association includes Name, Coverage, CPU Info, etc.
-- (see taste-deployment_view.ads for the complete list)
Partition_Assoc := Partition.Deployment_Partition.To_Template
& Assoc ("Threads", Threads)
& Assoc ("Thread_Names", Thread_Names)
& Assoc ("Node_Name", Node_Name)
& Assoc ("Blocks", Blocks)
& Assoc ("Block_Names", Block_Names)
& Assoc ("Block_Languages", Block_Languages)
& Assoc ("Thread_Src_Name", Thread_Src_Name)
& Assoc ("Thread_Src_Port", Thread_Src_Port)
& Assoc ("Thread_Dst_Name", Thread_Dst_Name)
& Assoc ("Thread_Dst_Port", Thread_Dst_Port);
& Assoc ("Threads", Threads)
& Assoc ("Thread_Names", Thread_Names)
& Assoc ("Node_Name", Node_Name)
& Assoc ("Blocks", Blocks)
& Assoc ("Block_Names", Block_Names)
& Assoc ("Block_Languages", Block_Languages)
& Assoc ("In_Port_Names", Input_Port_Names)
& Assoc ("In_Port_Thread_Name", Input_Port_Thread_Name)
& Assoc ("In_Port_Type_Name", Input_Port_Type_Name)
& Assoc ("Out_Port_Names", Output_Port_Names)
& Assoc ("Out_Port_Thread_Name", Output_Port_Thread_Name)
& Assoc ("Out_Port_Type_Name", Output_Port_Type_Name)
& Assoc ("Thread_Src_Name", Thread_Src_Name)
& Assoc ("Thread_Src_Port", Thread_Src_Port)
& Assoc ("Thread_Dst_Name", Thread_Dst_Name)
& Assoc ("Thread_Dst_Port", Thread_Dst_Port);
All_Target_Names := All_Target_Names
& String'(Get (Get (Partition_Assoc, "Package_Name")));
......@@ -461,6 +495,9 @@ package body TASTE.Concurrency_View is
Partition_CPU, -- Corresponding CPU name
Partition_Time, -- Corresponding TSP VP time
Partition_VP : Vector_Tag; -- for TSP: VP binding
Part_Source_Name,
Part_Source_Port,
Part_Dest_Name : Vector_Tag; -- Inter-partition connections (TSP)
begin
for Node in CV.Nodes.Iterate loop
declare
......@@ -534,6 +571,18 @@ package body TASTE.Concurrency_View is
Partition_Time := Partition_Time
& CV_Partitions.Element (Partition)
.Deployment_Partition.VP_Duration;
-- Create the inter-partition connections
for Out_Port of
CV_Partitions.Element (Partition).Out_Ports
loop
Part_Source_Name := Part_Source_Name
& CV_Partitions.Key (Partition);
Part_Source_Port := Part_Source_Port
& Out_Port.Port_Name;
Part_Dest_Name := Part_Dest_Name
& Out_Port.Remote_Partition_Name;
end loop;
end loop;
Nodes := Nodes & Newline & Node_Content;
......@@ -561,6 +610,9 @@ package body TASTE.Concurrency_View is
& Assoc ("Partition_CPU", Partition_CPU)
& Assoc ("Partition_Duration", Partition_Time)
& Assoc ("Partition_VP", Partition_VP)
& Assoc ("Part_Source_Name", Part_Source_Name)
& Assoc ("Part_Source_Port", Part_Source_Port)
& Assoc ("Part_Dest_Name", Part_Dest_Name)
& Assoc ("Threads", Threads)
& Assoc ("Thread_Names", All_Thread_Names)
& Assoc ("Target_Packages", All_Target_Names);
......
......@@ -57,7 +57,7 @@ package TASTE.Concurrency_View is
package Protected_Blocks is new Indefinite_Ordered_Maps
(String, Protected_Block);
type Port is
type Thread_Port is
record
Name : Unbounded_String;
Remote_Thread : Unbounded_String;
......@@ -65,7 +65,7 @@ package TASTE.Concurrency_View is
RI : Taste_Interface;
end record;
package Ports is new Indefinite_Ordered_Maps (String, Port);
package Ports is new Indefinite_Ordered_Maps (String, Thread_Port);
type AADL_Thread is tagged
record
......@@ -83,11 +83,21 @@ package TASTE.Concurrency_View is
package AADL_Threads is new Indefinite_Ordered_Maps (String, AADL_Thread);
type Partition_Port is
record
Port_Name, Thread_Name, Type_Name : Unbounded_String;
Remote_Partition_Name : Unbounded_String; -- Other side
end record;
package Partition_Ports is
new Indefinite_Ordered_Maps (String, Partition_Port);
type CV_Partition is tagged
record
Deployment_Partition : Taste_Partition;
Threads : AADL_Threads.Map;
Blocks : Protected_Blocks.Map;
In_Ports, Out_Ports : Partition_Ports.Map;
end record;
package CV_Partitions is new Indefinite_Ordered_Maps (String, CV_Partition);
......
......@@ -9,14 +9,6 @@
@@-- VP_Platforms : |_ Corresponding platform name
@@-- VP_Classifiers : |_ Corresponding aadl classifier
@@-- @_CPU_Name_@, _Family_@, Instance_@, _Platform_@, _Classifier_@, _Ada_Runtime_@ : Info about CPU
@@-- In standard TASTE systems there is only one partition per node
-- DEBUG : NODE_Name: @_Node_Name_@ CPU_Name : @_CPU_Name_@ Platform : @_CPU_Platform_@
-- Classifier : @_CPU_Classifier_@ Packagename : @_Package_Name_@ CPU : @_CPU_Family_@
-- VP Names: @_VP_Names_@
-- @_VP_Package_Names_@
-- @_VP_Platforms_@
-- @_VP_Classifiers_@
@@-- Test if the node contains several partitions (virtual processors)
@@-- If that's the case we need to generate a new AADL processor for TSP support
processor @_Node_Name_@_Board extends @_Package_Name_@::@_CPU_Family_@
......
......@@ -21,7 +21,31 @@
@@-- @_Thread_Dst_Name_@ : Vector tag : connection thread name (dest)
@@-- @_Thread_Src_Port_@ : Vector tag : connection port name (source)
@@-- @_Thread_Dst_Port_@ : Vector tag : connection port name (dest)
@@-- @_In_Port_Names_@ : Vector tag: input ports of the partition
@@-- @_In_Port_Thread_Name_@ : |_ corresponding thread inside the partition
@@-- @_In_Port_Type_Name_@ : |_ corresponding parameter type name (optional)
@@-- @_Out_Port_Names_@ : Vector tag: output ports of the partition
@@-- @_Out_Port_Thread_Name_@ : |_ corresponding thread inside the partition
@@-- @_Out_Port_Type_Name_@ : |_ corresponding parameter type name (optional)
process @_CAPITALIZE:Name_@ extends DeploymentView::DV::@_CAPITALIZE:Node_Name_@::@_CAPITALIZE:Name_@
@@IF@@ @_In_Port_Names'Length_@ > 0 or @_Out_Port_Names'Length_@ > 0
features
@@TABLE@@
@@IF@@ @_In_Port_Type_Name_@ /= ""
INPORT_@_In_Port_Names_@ : in event data port DataView::@_REPLACE_ALL(-/_):In_Port_Type_Name_@_Buffer.impl;
@@ELSE@@
INPORT_@_In_Port_Names_@ : in event port;
@@END_IF@@
@@END_TABLE@@
@@TABLE@@
@@IF@@ @_Out_Port_Type_Name_@ /= ""
OUTPORT_@_Out_Port_Names_@ : out event data port DataView::@_REPLACE_ALL(-/_):Out_Port_Type_Name_@_Buffer.impl;
@@ELSE@@
OUTPORT_@_Out_Port_Names_@ : out event port;
@@END_IF@@
@@END_TABLE@@
@@END_IF@@
end @_Name_@;
process implementation @_CAPITALIZE:Name_@.final
......@@ -30,10 +54,17 @@ subcomponents
@@TABLE'ALIGN_ON(":")@@
@_Thread_Names_@ : thread @_Thread_Names_@_Thread::@_Thread_Names_@.others;
@@END_TABLE@@
@@IF@@ @_Thread_Src_Name'Length_@ > 0
@@IF@@ @_Thread_Src_Name'Length_@ > 0 or @_In_Port_Names'Length_@ > 0 or @_Out_Port_Names'Length_@ > 0
connections
@@TABLE'ALIGN_ON(":","->")@@
port @_CAPITALIZE:Thread_Src_Name_@.OUTPORT_@_CAPITALIZE:Thread_Src_Port_@ -> @_CAPITALIZE:Thread_Dst_Name_@.INPORT_@_CAPITALIZE:Thread_Dst_Port_@;
@@END_TABLE@@
@@-- connect the partition ports to the threads (happens in distributed or TSP systems only)
@@TABLE@@
port INPORT_@_In_Port_Names_@ -> @_In_Port_Thread_Name_@.INPORT_@_In_Port_Names_@;
@@END_TABLE@@
@@TABLE@@
port @_Out_Port_Thread_Name_@.OUTPORT_@_Out_Port_Names_@ -> OUTPORT_@_Out_Port_Names_@;
@@END_TABLE@@
@@END_IF@@
end @_CAPITALIZE:Name_@.final;
......@@ -13,6 +13,9 @@
@@-- @_Threads_@ : Code generated for the threads
@@-- @_Thread_Names_@ : List of all threads in the complete system
@@-- @_Target_Packages_@ : List of all target package names in the complete system
@@-- @_Part_Source_Name_@ : Inter-partition connections : partition source name (vector tag)
@@-- @_Part_Source_Port_@ : |_ Corresponding port name
@@-- @_Part_Dest_Name_@ : |_ Corresponding name of the remote partition
@@-- And all the system configuration obtained from the command line:
@@-- Interface_View, Deployment_View, Data_View, Binary_Path, Check_Data_View,
@@-- Output_Dir, Skeletons, Glue, Use_POHIC, Timer_Resolution, Debug_Flag,
......@@ -71,6 +74,13 @@ subcomponents
@_CAPITALIZE:Node_Names_@_Memory : memory deploymentview::DV::@_CAPITALIZE:Node_Names_@::main_memory.others;
@@END_IF@@
@@END_TABLE@@
@@-- Specify the cconnections for distributed and TSP systems
@@IF@@ @_Part_Source_Name'Length_@ > 0
connections
@@TABLE@@
@_Part_Source_Name_@_@_Part_Source_Port_@ : port @_Part_Source_Name_@.OUTPORT_@_Part_Source_Port_@ -> @_Part_Dest_Name_@.INPORT_@_Part_Source_Port_@;
@@END_TABLE@@
@@END_IF@@
@@-- Then specify the bindings of the partitions to (virtual) processors
properties
@@TABLE'ALIGN_ON("applies")@@
......
KAZOO=../../kazoo
all: test-parse
cp input_data/hello.c output/hello/C/src && \
cp input_data/read.c output/read/C/src && \
cd output/build && ocarina -x main.aadl
test-parse: clean
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment