------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2010, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- the LISyC Team, University of Western Britanny. -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 97 $ -- $Date: 2007-07-20 15:17:15 +0200 (Fri, 20 Jul 2007) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Numerics.Aux; use Ada.Numerics.Aux; with Text_IO; use Text_IO; with Framework_Config; use Framework_Config; with Processor_Set; use Processor_Set; use Processor_Set.Generic_Processor_Set; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; use unbounded_strings.strings_table_package; use unbounded_strings.unbounded_string_list_package; with Parameters; use Parameters; with Parameters.extended; use Parameters.extended; use Parameters.Framework_Parameters_Table_Package; with Scheduler_Interface; use Scheduler_Interface; with Processor_Set; use Processor_Set; use Processor_Set.Generic_Processor_Set; with Processors; use Processors; with processor_interface; use processor_interface; with Caches; use Caches; use Caches.Caches_Table_Package; use Processors.Core_Units_Table_Package; with Address_Space_Set; use Address_Space_Set; use Address_Space_Set.Generic_Address_Space_Set; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Systems; use Systems; with Call_Framework; use Call_Framework; with Call_Framework_Interface; use Call_Framework_Interface; use Call_Framework_Interface.Framework_Response_Package; use Call_Framework_Interface.Framework_Request_Package; with framework; use framework; with Call_Scheduling_Framework; use Call_Scheduling_Framework; with Multiprocessor_Services; use Multiprocessor_Services; with Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface; use Multiprocessor_Services_Interface.Scheduling_Result_Per_Processor_Package; with GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with Version; use Version; with Ada.Exceptions; use Ada.Exceptions; with Task_Groups; use Task_Groups; with Task_Group_Set; use Task_Group_Set; with Tasks; use Tasks; with Task_Dependencies; use Task_Dependencies; with Architecture_Factory; use Architecture_Factory; with Task_Group_Transformation; use Task_Group_Transformation; with Comprehensive_Call; procedure DGMF2Transaction is procedure Usage is begin Put_Line("This program generates a DGMF system, transforms it into a Transaction system and simulates both systems. It generates a xml for both simulations."); New_Line; Put_Line ("Usage : dgmf2transaction [options]"); Put_Line (" [options] :"); Put_Line (" -h This message"); Put_Line (" -v Verbose mode"); Put_Line (" -g : Integer"); Put_Line (" -f : Integer"); Put_Line (" -r : Integer"); Put_Line (" -u : Integer"); Put_Line (" -p : Integer"); Put_Line (" -c : Integer"); Put_Line (" -a : Integer"); Put_Line (" -s : Integer"); Put_Line (" -m : Integer"); Put_Line (" -y : Integer"); Put_Line (" -d : Integer"); New_Line; end Usage; procedure Compute_Scheduling (A_Sys : in out System; File_Name : in Unbounded_String; Debug : in Boolean := False) is Response_List : Framework_Response_Table; Request_List : Framework_Request_Table; A_Request : Framework_Request; A_Param : Parameter_ptr; begin Initialize (Response_List); Initialize (Request_List); Initialize (A_Request); A_Request.Statement := Scheduling_Simulation_Time_Line; A_Param := new Parameter (Integer_Parameter); A_Param.Name := To_Unbounded_String ("period"); A_Param.Integer_value := Scheduling_Period_With_Offset(A_Sys.tasks); Add (A_Request.Param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.Name := To_Unbounded_String ("schedule_with_offsets"); A_Param.Boolean_value := True; Add (A_Request.Param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.Name := To_Unbounded_String ("task_activation"); A_Param.Boolean_value := False; Add (A_Request.Param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.Name := To_Unbounded_String ("schedule_with_precedencies"); A_Param.Boolean_value := True; Add (A_Request.Param, A_Param); A_Param := new Parameter (Boolean_Parameter); A_Param.Name := To_Unbounded_String ("schedule_with_resources"); A_Param.Boolean_value := True; Add (A_Request.Param, A_Param); A_Param := new Parameter (Integer_Parameter); A_Param.Name := To_Unbounded_String ("seed_value"); A_Param.Integer_value := 0; Add (A_Request.Param, A_Param); Add (Request_List, A_Request); Sequential_Framework_Request (A_Sys, Request_List, Response_List); if Debug then Put_Line (To_String (Response_List.Entries (0).Title)); for J in 0 .. Response_List.Nb_Entries - 1 loop Put_Line (To_String (Response_List.Entries (J).Text)); end loop; end if; Write_To_Xml_File (Framework.Sched, A_Sys, Suppress_Space(File_Name)); end Compute_Scheduling; Sys_Multiframe : System; Sys_Transaction : System; Number_Groups : Integer := 2; Number_Frames : Integer := 10; Number_Resources : Integer := 1; Number_Usages : Integer := 2; Number_Cores : Integer := 1; Number_Processors : Integer := 1; Number_Addrs : Integer := 1; Sched : Schedulers_Type := Posix_1003_Highest_Priority_First_Protocol; MF_Period : Integer := 10; Sync_Ratio : Double := 0.5; Number_Precedences : Integer := 1; Output_File_Name : Unbounded_String := Empty_String; Verbose : Boolean := False; No_Error : Boolean := False; begin -- Get arguments loop case GNAT.Command_Line.Getopt("h v o: g: f: r: u: c: p: a: s: m: y: d:") is when ASCII.NUL => No_Error := true; exit; when 'o' => Output_File_Name := To_Unbounded_String(GNAT.Command_Line.Parameter); when 'g' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Groups, No_Error); if not No_Error then exit; end if; when 'f' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Frames, No_Error); if not No_Error then exit; end if; when 'r' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Resources, No_Error); if not No_Error then exit; end if; when 'u' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Usages, No_Error); if not No_Error then exit; end if; when 'c' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Cores, No_Error); if not No_Error then exit; end if; when 'p' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Processors, No_Error); if not No_Error then exit; end if; when 'a' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Addrs, No_Error); if not No_Error then exit; end if; when 's' => To_Schedulers_Type(GNAT.Command_Line.Parameter, Sched, No_Error); if not No_Error then exit; end if; when 'm' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), MF_Period, No_Error); if not No_Error then exit; end if; when 'y' => To_Double(To_Unbounded_String(GNAT.Command_Line.Parameter), Sync_Ratio, No_Error); if not No_Error then exit; end if; when 'd' => To_Integer(To_Unbounded_String(GNAT.Command_Line.Parameter), Number_Precedences, No_Error); if not No_Error then exit; end if; when 'v' => Verbose := True; when 'h' => Usage; OS_Exit(0); when others => Usage; OS_Exit(0); end case; end loop; if not No_Error then Put_Line("Error in given options, please verify their values."); OS_Exit(1); end if; if Verbose then Put_Line ("DGMF 2 Transaction will be launched with the following parameters:"); Put_Line (" - Number_Groups:" & Number_Groups'Img); Put_Line (" - Number_Frames:" & Number_Frames'Img); Put_Line (" - Number_Resources:" & Number_Resources'Img); Put_Line (" - Number_Usages:" & Number_Usages'Img); Put_Line (" - Number_Cores:" & Number_Cores'Img); Put_Line (" - Number_Processors:" & Number_Processors'Img); Put_Line (" - Number_Addrs:" & Number_Addrs'Img); Put_Line (" - Sched: " & Sched'Img); Put_Line (" - MF_Period:" & MF_Period'Img); Put_Line (" - Sync_Ratio:" & Sync_Ratio'Img); Put_Line (" - Number_Precedences:" & Number_Precedences'Img); New_Line; end if; Create_MF_System (Sys_Multiframe, Number_Groups, -- number_groups Number_Frames, -- number_frames Number_Resources, -- number_Resources Number_Usages, -- number_resource_usages Number_Cores, -- number_Core_Units_Per_Processor Number_Processors, -- number_Processors Number_Addrs, -- number_Address_Spaces (< Number_Processors means an Addr is added to each CPU automatically) Sched, -- Sched MF_Period, -- mf_period Sync_Ratio, -- sync_percentage Number_Precedences);-- number_precedences Write_To_Xml_File(Sys_Multiframe, To_Unbounded_String ("sys_multiframe_" & To_String(Output_File_Name) & ".xml")); Multiframe_To_Transaction_Sys_Crossref(Sys_Multiframe, Sys_Transaction); Write_To_Xml_File(Sys_Transaction, To_Unbounded_String ("sys_transaction_" & To_String(Output_File_Name) & ".xml")); Compute_Scheduling(Sys_Multiframe, To_Unbounded_String("sched_multiframe_" & To_String(Output_File_Name) & ".xml"), FALSE); Compute_Scheduling(Sys_Transaction, To_Unbounded_String("sched_transaction_" & To_String(Output_File_Name) & ".xml"), FALSE); if Verbose then Put_Line ("Scheduling result files sched_multiframe_" & To_String(Output_File_Name) & ".xml and sched_transaction_" & To_String(Output_File_Name) & ".xml have been created"); end if; -- Compute_Scheduling(Sys_Multiframe, to_unbounded_string("sched_multiframe_" -- & Number_Groups'Img -- & Number_Frames'Img -- & Number_Resources'Img -- & Number_Usages'Img -- & Number_Cores'Img -- & Number_Processors'Img -- & Number_Addrs'Img -- & Sched -- & MF_Period'Img -- & Sync_Ratio'Img)); -- -- Compute_Scheduling(Sys_Transaction, to_unbounded_string("sched_transaction_" -- & Number_Groups'Img -- & Number_Frames'Img -- & Number_Resources'Img -- & Number_Usages'Img -- & Number_Cores'Img -- & Number_Processors'Img -- & Number_Addrs'Img -- & Sched -- & MF_Period'Img -- & Sync_Ratio'Img)); -- -- Constants: 2 processors, 2 cores/processor, sched=hpf, sync_percentage=0.5 -- for number_groups in 2 .. 10 loop -- put_line("number_groups =" & number_groups'Img); -- number_frames := number_groups; -- while (number_frames < 100) loop -- number_frames := number_frames + 10; -- if (number_frames > 100) then -- number_frames := 100; -- end if; -- put_line(" number_frames =" & number_frames'Img); -- for number_resources in 3 .. 3 loop -- put_line(" number_resources=" & number_resources'Img); -- -- TODO: max resource usages -- for number_resource_usages in 10 .. 10 loop -- put_line(" number_usages=" & number_resource_usages'Img); -- -- TODO: max_dependencies -- for number_precedences in number_frames/2 .. number_frames loop -- put_line(" number_precs=" & number_precedences'Img); -- mf_period := 0; -- while (mf_period < 1000) loop -- mf_period := mf_period + 100; -- put_line(" mf_period=" & mf_period'Img); -- -- Create_MF_System -- (Sys_Multiframe, -- number_groups, -- number_groups -- number_frames, -- number_frames -- number_resources, -- number_Resources -- number_resource_usages, -- number_resource_usages -- NUMBER_CORES, -- number_Core_Units_Per_Processor -- NUMBER_PROCESSORS, -- number_Processors -- 0, -- number_Address_Spaces (< Number_Processors means an Addr is added to each CPU automatically) -- Posix_1003_Highest_Priority_First_Protocol, -- Sched -- mf_period, -- mf_period -- SYNC_RATIO, -- sync_percentage -- number_precedences);-- number_precedences -- -- -- Write_To_Xml_File -- -- (Sys_Multiframe, -- -- suppress_space( -- -- To_Unbounded_String( -- -- "Multiframe_" & -- -- number_groups'Img & "_" & -- -- number_frames'Img & "_" & -- -- number_resources'Img & "_" & -- -- number_resource_usages'Img & "_" & -- -- NUMBER_CORES'Img & "_" & -- -- NUMBER_PROCESSORS'Img & "_" & -- -- Integer(0)'Img & "_" & -- -- "HPF" & "_" & -- -- mf_period'Img & "_" & -- -- Integer(SYNC_RATIO * 100.0)'Img & "_" & -- -- number_precedences'Img & "_" & -- -- ".xml"))); -- -- -- Transformation -- --Multiframe_To_Transaction_Sys_Crossref(Sys_Multiframe, Sys_Transaction); -- -- -- Write_To_Xml_File -- -- (Sys_Multiframe, -- -- suppress_space( -- -- "Transaction_" & -- -- number_groups'Img & "_" & -- -- number_frames'Img & "_" & -- -- number_resources'Img & "_" & -- -- number_resource_usages'Img & "_" & -- -- NUMBER_CORES'Img & "_" & -- -- NUMBER_PROCESSORS'Img & "_" & -- -- Integer(SYNC_RATIO * 100.0)'Img & "_" & -- -- "HPF" & "_" & -- -- mf_period'Img & "_" & -- -- SYNC_RATIO'Img & "_" & -- -- number_precedences'Img & "_" & -- -- ".xml")); -- -- --Compute_Scheduling(Sys_Multiframe, to_unbounded_string("sched_multiframe.xml")); -- --Compute_Scheduling(Sys_Transaction, to_unbounded_string("sched_transaction.xml")); -- end loop; -- end loop; -- end loop; -- end loop; -- end loop; -- end loop; -- Create_MF_System -- (Sys_Multiframe, -- 5, -- number_groups -- 30, -- number_frames -- 6, -- number_Resources -- 15, -- number_resource_usages -- 2, -- number_Core_Units_Per_Processor -- 2, -- number_Processors -- 0, -- number_Address_Spaces (< Number_Processors means an Addr is added to each CPU automatically) -- Posix_1003_Highest_Priority_First_Protocol, -- Sched -- 5000, -- mf_period -- 0.5, -- sync_percentage -- 5);-- number_precedences -- -- Write_To_Xml_File -- (Sys_Multiframe, -- To_Unbounded_String ("sys_multiframe_generated.xml")); -- -- -- Transformation -- Multiframe_To_Transaction_Sys_Crossref(Sys_Multiframe, Sys_Transaction); -- -- Write_To_Xml_File -- (Sys_Transaction, -- To_Unbounded_String ("sys_transaction_generated.xml")); -- -- Compute_Scheduling(Sys_Multiframe, to_unbounded_string("sched_multiframe.xml")); -- Compute_Scheduling(Sys_Transaction, to_unbounded_string("sched_transaction.xml")); end DGMF2Transaction;