Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/rtlmeter/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0

import multiprocessing
import os
import time
from functools import cached_property
Expand Down Expand Up @@ -77,10 +78,12 @@ def availableCases(self) -> List[str]:
value.append(f"{designName}:{configName}:{testName}")
return sorted(value)

# CPUs usable by this process
# Number of logical processors usable by this process
@cached_property
def usableCpus(self) -> List[int]:
return sorted(_ for _ in os.sched_getaffinity(0))
def nProc(self) -> int:
if hasattr(os, "sched_getaffinity"):
return len(os.sched_getaffinity(0))
return multiprocessing.cpu_count()

# Set deadline to now + 'timeout' minutes
def setTimeout(self, timeout: Optional[int]) -> None:
Expand Down
8 changes: 7 additions & 1 deletion src/rtlmeter/runcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import shlex
import stat
import subprocess
import sys
import time
from typing import Dict, Final, List

Expand All @@ -34,6 +35,11 @@
"""


TIME_CMD = "time"
if sys.platform == "darwin":
TIME_CMD = "gtime" # On macOS use GNU time


def runcmd(
cmd: List[str], # Command + arguments
tag: str, # Tag string to use for log and marker files
Expand Down Expand Up @@ -67,7 +73,7 @@ def runcmd(

# Actual command line to run, using the cmd file
timeFile = os.path.join(tagDir, "time.json")
cmd = ["time", "-o", timeFile, "-f", _TIMEFORMAT, cmdFileName]
cmd = [TIME_CMD, "-o", timeFile, "-f", _TIMEFORMAT, cmdFileName]

# Apply timeout if a deadline is set
if (timeout := CTX.timeout()) is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/rtlmeter/verilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def job() -> bool:
cmd = [
"make",
"-j",
str(len(CTX.usableCpus)),
str(CTX.nProc),
"-C",
"obj_dir",
"-f",
Expand Down