Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9054793
move prettytable into inc.common
xin3he Jun 24, 2024
fd510db
add benchmark
xin3he Jun 25, 2024
29f974c
support windows
xin3he Jun 26, 2024
dabe436
fix bug
xin3he Jun 26, 2024
4f7cb7c
enable subprocess running
xin3he Jun 26, 2024
4a3b6cd
fix bug in windows
xin3he Jun 26, 2024
3cc3885
enhance log
xin3he Jun 26, 2024
b3c1091
add document
xin3he Jun 26, 2024
ca1f3b6
update platform status
xin3he Jun 26, 2024
29ebf1a
add incbench dlrm example
xin3he Jun 27, 2024
5960bb7
add more docstring
xin3he Jun 27, 2024
4c15bda
add performance test for sq opt-125m
xin3he Jun 28, 2024
60340f2
enhance pre-commit for max-line-length check
xin3he Jun 28, 2024
5f02407
add Multiple Instance Benchmark Summary
xin3he Jun 28, 2024
cc014af
Dump Throughput and Latency Summary
xin3he Jun 28, 2024
c3de633
change log folder and add UTs
xin3he Jul 1, 2024
9757779
add requirement
xin3he Jul 1, 2024
6ca810f
Merge branch 'master' into xinhe/benchmark
xin3he Jul 2, 2024
8549e92
improve UT coverage
xin3he Jul 3, 2024
0f6e057
fix pylint
xin3he Jul 3, 2024
7f3aff5
remove previous useless code
xin3he Jul 8, 2024
eeb56f6
fix bug
xin3he Jul 8, 2024
24ec333
fix pylint
xin3he Jul 8, 2024
18ca594
fix bug
xin3he Jul 8, 2024
b55b22b
Merge branch 'master' into xinhe/benchmark
chensuyue Jul 9, 2024
a524d9c
update summary format per suyue's request
xin3he Jul 9, 2024
245c75a
fdsa
xin3he Jul 9, 2024
81687bd
revert pre-commit change
xin3he Jul 9, 2024
d681fc7
Merge branch 'master' into xinhe/benchmark
xin3he Jul 10, 2024
7e73d1a
update UT
xin3he Jul 10, 2024
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
Prev Previous commit
Next Next commit
support windows
Signed-off-by: xin3he <[email protected]>
  • Loading branch information
xin3he committed Jun 26, 2024
commit 29f974c9bfe0e9a585dbcaad7601217af9cfcff1
81 changes: 77 additions & 4 deletions neural_compressor/common/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@


def get_linux_numa_info():
"""Collect numa/socket information on linux system.

Returns:
numa_info (dict): demo: {numa_index: {"physical_cpus": "xxx"; "logical_cpus": "xxx"}}
E.g. numa_info = {
0: {"physical_cpus": "0-23", "logical_cpus": "0-23,48-71"},
1: {"physical_cpus": "24-47", "logical_cpus": "24-47,72-95"}
}
"""
result = subprocess.run(["lscpu"], capture_output=True, text=True)
output = result.stdout

Expand All @@ -60,18 +69,82 @@ def get_linux_numa_info():
cpus = node_match.group(2).strip()
numa_info[node_id] = {
"physical_cpus": cpus.split(",")[0],
"logical_cpus": cpus.split(","),
"logical_cpus": ",".join(cpus.split(",")),
}

# if numa_info is not collected, we go back to socket_info
if not numa_info:
for line in output.splitlines():
# demo: "Socket(s): 2"
socket_match = re.match(r"^Socket\(s\):\s+(.*)$", line)
if socket_match:
num_socket = int(socket_match.group(1))
# process big cores (w/ physical cores) and small cores (w/o physical cores)
physical_cpus = psutil.cpu_count(logical=False)
logical_cpus = psutil.cpu_count(logical=True)
physical_cpus_per_socket = physical_cpus // num_socket
logical_cpus_per_socket = logical_cpus // num_socket
for i in range(num_socket):
physical_cpus_str = str(i * physical_cpus_per_socket) + "-" + str((i + 1) * physical_cpus_per_socket - 1)
if num_socket == 1:
logical_cpus_str = str(i * logical_cpus_per_socket) + "-" + str((i + 1) * logical_cpus_per_socket - 1)
else:
remain_cpus = logical_cpus_per_socket - physical_cpus_per_socket
logical_cpus_str = (
physical_cpus_str
+ ","
+ str(i * (remain_cpus) + physical_cpus)
+ "-"
+ str((i + 1) * remain_cpus + physical_cpus - 1)
)
numa_info[i] = {
"physical_cpus": physical_cpus_str,
"logical_cpus": logical_cpus_str,
}
return numa_info


def get_windows_numa_info():
# pip install WMI
"""Collect socket information on Windows system due to no available numa info.

Returns:
numa_info (dict): demo: {numa_index: {"physical_cpus": "xxx"; "logical_cpus": "xxx"}}
E.g. numa_info = {
0: {"physical_cpus": "0-23", "logical_cpus": "0-23,48-71"},
1: {"physical_cpus": "24-47", "logical_cpus": "24-47,72-95"}
}
"""
import wmi

c = wmi.WMI()
numa_nodes = c.Win32_ComputerSystem()
print(f"Number of NUMA node: {len(numa_nodes)}")
processors = c.Win32_Processor()
socket_designations = set()
for processor in processors:
socket_designations.add(processor.SocketDesignation)
num_socket = len(socket_designations)
physical_cpus = sum(processor.NumberOfCores for processor in processors)
logical_cpus = sum(processor.NumberOfLogicalProcessors for processor in processors)
physical_cpus_per_socket = physical_cpus // num_socket
logical_cpus_per_socket = logical_cpus // num_socket

numa_info = {}
for i in range(num_socket):
physical_cpus_str = str(i * physical_cpus_per_socket) + "-" + str((i + 1) * physical_cpus_per_socket - 1)
if num_socket == 1:
logical_cpus_str = str(i * logical_cpus_per_socket) + "-" + str((i + 1) * logical_cpus_per_socket - 1)
else:
remain_cpus = logical_cpus_per_socket - physical_cpus_per_socket
logical_cpus_str = (
physical_cpus_str
+ ","
+ str(i * (remain_cpus) + physical_cpus)
+ "-"
+ str((i + 1) * remain_cpus + physical_cpus - 1)
)
numa_info[i] = {
"physical_cpus": physical_cpus_str,
"logical_cpus": logical_cpus_str,
}


def dump_numa_info():
Expand Down