Skip to content

Commit 84bb70e

Browse files
add rt cores
1 parent fea1ac6 commit 84bb70e

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

conf/config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,21 @@ demo:
5757
io_system:
5858
ip: 10.34.106.119
5959
nic: enp3s0
60-
ssh_user: user
61-
ssh_password: "password" # set SSH_PASSWORD env var, or use key-based auth
60+
ssh_user: intel
61+
ssh_password: "Qwepoi!23" # set SSH_PASSWORD env var, or use key-based auth
6262
ssh_port: 22
6363
# Host-side IP on the macvlan subnet (must not clash with any container IP).
6464
# Allows the IO host to reach containers via: curl http://192.168.10.12:8080
6565
shim_ip: 192.168.10.253
66+
t_cpus: "1,3"
6667
control_system:
6768
ip: localhost
6869
nic: eno12399np0
6970
# Host-side IP on the macvlan subnet (must not clash with any container IP).
7071
# Allows the control host to reach containers via: curl http://192.168.10.15:8080
7172
shim_ip: 192.168.10.254
73+
t_cpus: "3,5,7,9"
74+
t_mems: "1"
7275

7376
# Map host_ip:<host_port> → container_ip:<container_port> via iptables.
7477
# This lets external clients access container services

src/hde2e.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,24 @@ def _sudo_cmd(self, cmd: str) -> str:
6666
pw = self._resolve_sudo_password()
6767
# Use printf to avoid issues with special chars in the password.
6868
return f"printf '%s\\n' '{pw}' | sudo -S {cmd}"
69-
69+
def _realtime_core_control(self, instance_num: str) -> Optional[str]:
70+
"""Return a CPU core list string for the real-time Control PLC instance."""
71+
# Example mapping: Control_PLC_01 → cores 0-3, Control_PLC_02 → cores 4-7
72+
t_cpus = self.config.demo.control_system.get("t_cpus")
73+
t_cpus = t_cpus.split(",")
74+
if len(t_cpus) < 4:
75+
print("[WARN] Not enough t_cpus specified for control_system. Expected at least 4.")
76+
return None
77+
if instance_num == "01":
78+
return f"{t_cpus[int(instance_num)-1]},{t_cpus[int(instance_num)]}" # cores 3,5
79+
elif instance_num == "02":
80+
return f"{t_cpus[int(instance_num)]},{t_cpus[len(t_cpus)-1]}" # cores 7,9
81+
def _realtime_core_io(self, instance_num: str) -> Optional[str]:
82+
"""Return a CPU core list string for the real-time IO PLC instance."""
83+
# Example mapping: IO_PLC_01 → cores 8-11, IO_PLC_02 → cores 12-15
84+
t_cpus = self.config.demo.io_system.get("t_cpus")
85+
t_cpus = t_cpus.split(",")
86+
return str(t_cpus[instance_num - 1])
7087
# Low-level helpers
7188
@staticmethod
7289
def _run_command(cmd: List[str], capture: bool = False) -> subprocess.CompletedProcess:
@@ -540,7 +557,7 @@ def launch_instance(
540557
# 1. Resolve the container IP from the JSON config
541558
container_ip = self._extract_ip_from_config(app_type, instance_num)
542559

543-
cpuset_cpus = cpuset_cpus or self.config.demo.get("cpuset_cpus")
560+
cpuset_cpus = self._realtime_core_io(int(instance_num)) if app_type == "io" else self._realtime_core_control(instance_num)
544561
cpuset_mems = cpuset_mems or self.config.demo.get("cpuset_mems")
545562
if not container_ip:
546563
print(f"[ERROR] No IP found for {container_name}")
@@ -654,6 +671,8 @@ def start_control(self) -> int:
654671
ssh=None,
655672
network=DEFAULT_NETWORK,
656673
nic=nic,
674+
cpuset_mems=self.config.demo.control_system.get("cpuset_mems"),
675+
cpuset_cpus=self._realtime_core_control(instance_num),
657676
)
658677
if rc != 0:
659678
return rc
@@ -700,6 +719,7 @@ def start_io(self) -> int:
700719
ssh=ssh,
701720
network=DEFAULT_NETWORK,
702721
nic=nic,
722+
cpuset_cpus=self._realtime_core_io(int(instance_num)),
703723
)
704724
if rc != 0:
705725
return rc

0 commit comments

Comments
 (0)