Commit 2b5741ad authored by yoogx's avatar yoogx
Browse files

* Implement new accessors to get the list of processors an

          entity is bound to, get number of cores, etc.

          For openaadl/ocarina#180
parent 22d88edb
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2019 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -2283,6 +2283,24 @@ package body Ocarina.Backends.Properties is
return Get_Reference_Property (P, Processor_Binding);
end Get_Bound_Processor;
---------------------------
-- Get_Bound_Processor_L --
---------------------------
function Get_Bound_Processor_L (P : Node_Id) return List_Id is
begin
if not Is_Defined_Reference_Property (P, Processor_Binding)
and then Is_Process (P)
then
Display_Located_Error
(AIN.Loc (Parent_Subcomponent (P)),
"This process has to be bound to a processor",
Fatal => True);
end if;
return Get_List_Property (P, Processor_Binding);
end Get_Bound_Processor_L;
----------------------
-- Get_Bound_Memory --
----------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2019 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -506,6 +506,7 @@ package Ocarina.Backends.Properties is
----------------------------------
function Get_Bound_Processor (P : Node_Id) return Node_Id;
function Get_Bound_Processor_L (P : Node_Id) return List_Id;
-- Return the processor component to which the process P is
-- bound. Raises an error if P is not bound to any processor.
......@@ -622,9 +623,9 @@ package Ocarina.Backends.Properties is
E : Node_Id := No_Node) return Supported_Transport_APIs;
-- Return the transport layer supported by the bus B
----------------------
---------------------
-- Port properties --
----------------------
---------------------
type Supported_Port_Timing is
(Port_Timing_Sampled,
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2019 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -47,6 +47,8 @@ with Ocarina.Backends.Messages;
with Ocarina.Backends.Ada_Tree.Nodes;
with Ocarina.Backends.Ada_Tree.Nutils;
with Ocarina.Backends.Ada_Values;
with Ocarina.Instances.Queries;
with Ocarina.Backends.Helper;
package body Ocarina.Backends.Utils is
......@@ -69,6 +71,8 @@ package body Ocarina.Backends.Utils is
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.Messages;
use Ocarina.Backends.Ada_Tree.Nutils;
use Ocarina.Instances.Queries;
use Ocarina.Backends.Helper;
-- The entered directories stack
......@@ -4095,6 +4099,43 @@ package body Ocarina.Backends.Utils is
return Core_Id;
end Get_Core_Id;
-------------
-- Is_Core --
-------------
function Is_Core (VP : Node_Id) return Boolean is
begin
return Is_Virtual_Processor (VP) and then
Is_Defined_Property (VP, "processor_properties::core_id");
end Is_Core;
------------------
-- Is_Partition --
------------------
function Is_Partition (VP : Node_Id) return Boolean is
begin
return Is_Virtual_Processor (VP) and then
Is_Defined_Property (VP, "deployment::execution_platform");
end Is_Partition;
-------------------------
-- Get_Number_Of_Cores --
-------------------------
function Get_Number_Of_Cores (P : Node_Id) return Unsigned_Long_Long is
Number_Of_Cores : Unsigned_Long_Long := 0;
begin
for Elt of Subcomponents_Of (P) loop
if Is_Core (Corresponding_Instance (Elt)) then
Number_Of_Cores := Number_Of_Cores + 1;
end if;
end loop;
return Number_Of_Cores;
end Get_Number_Of_Cores;
------------------------------
-- Visit_Subcomponents_Of_G --
------------------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2019 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -502,4 +502,16 @@ package Ocarina.Backends.Utils is
function Get_Core_Id (D : Node_Id) return Unsigned_Long_Long;
-- Return the id of the core D is bound to
function Is_Core (VP : Node_Id) return Boolean;
-- Return true iff VP is a virtual processor denoting a core,
-- i.e. it has the Processors::Core_Id property defined.
function Is_Partition (VP : Node_Id) return Boolean;
-- Return true iff VP is a virtual processor denoting a logical
-- partition, i.e. it has the Deployment::Deployment_Platform
-- property defined.
function Get_Number_Of_Cores (P : Node_Id) return Unsigned_Long_Long;
-- Return the number of cores attached to the processor P
end Ocarina.Backends.Utils;
Supports Markdown
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