Skip to content

Commit

Permalink
Further reduce Python dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
breyerml committed Nov 28, 2024
1 parent 48e5074 commit 7c02de9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 106 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ else ()
message(FATAL_ERROR "Can't find Python3. Please manually specify PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!")
endif ()

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_python_libs.cmake)
set(PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS pylspci)
message(STATUS "Checking required Python3 libraries (${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS}) to automatically determine the PLSSVM_TARGET_PLATFORMS.")
set(PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS_ERROR_MESSAGE "or manually define PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!")
check_python_libs(${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS} ${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS_ERROR_MESSAGE})

# run our `plssvm_target_platforms.py` script to determine the PLSSVM_TARGET_PLATFORMS string
execute_process(
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/utility_scripts/plssvm_target_platforms.py" "--quiet"
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,9 @@ Valid targets are:
- `intel`: compile for Intel GPUs; **at least one** architectural specification is necessary, e.g., `intel:skl`

At least one of the above targets must be present. If the option `PLSSVM_TARGET_PLATFORMS` is not present, the targets
are automatically determined using the Python3 `utility_scripts/plssvm_target_platforms.py` script (required Python3 dependencies:
[`argparse`](https://docs.python.org/3/library/argparse.html), and [`pylspci`](https://pypi.org/project/pylspci/)).
are automatically determined using the Python3 `utility_scripts/plssvm_target_platforms.py` script.

Note that when using DPC++ only a single architectural specification for `cpu`, `nvidia` or `amd` is allowed and that
automatically retrieving AMD GPU information on Windows is currently not supported due to `pyamdgpuinfo` limitations.
Note that when using DPC++ only a single architectural specification for `cpu`, `nvidia` or `amd` is allowed.


```bash
Expand Down
13 changes: 1 addition & 12 deletions install/python_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
### optional and required python packages

## for the data set generation
# LIBSVM
argparse
## for the data set generation (LIBSVM file format)
scikit-learn
humanize

Expand All @@ -17,20 +15,11 @@ pandas
# for plotting the generated data set (only available if #features <= 3)
matplotlib


## for the automatic PLSSVM target platform determination
# argparse
pylspci


## for the performance tracker parser
# argparse
# matplotlib
pyyaml
pint


## for the performance analysis
# argparse
# scikit-learn
wrapt-timeout-decorator
100 changes: 16 additions & 84 deletions utility_scripts/plssvm_target_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from pathlib import Path
import subprocess

import pylspci # get Intel GPU information

# parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--quiet", help="only output the final PLSSVM_TARGET_PLATFORMS string", action="store_true")
Expand All @@ -29,62 +27,6 @@ def cond_print(msg=""):
print(msg)


# TODO: maybe use "lspci -nn |grep -Ei 'VGA|DISPLAY'" ?
# mapping of Intel architecture names
# https://dgpu-docs.intel.com/devices/hardware-table.html
# https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html
intel_arch_mapping = {
# Skylake
"skl": ["192A", "1932", "193B", "193A", "193D", "1923", "1926", "1927", "192B", "192D", "1912", "191B", "1913",
"1915", "1917", "191A", "1916", "1921", "191D", "191E", "1902", "1906", "190B", "190A", "190E"],
# Gemini Lake
"glk": ["3185", "3184"],
# Apollo Lake
"Gen9": ["1A85", "5A85", "0A84", "1A84", "5A84"],
# Kaby Lake
"kbl": ["593B", "5923", "5926", "5927", "5917", "5912", "591B", "5916", "5921", "591A", "591D", "591E", "591C",
"87C0", "5913", "5915", "5902", "5906", "590B", "590A", "5908", "590E"],
# Coffee Lake
"cfl": ["3EA5", "3EA8", "3EA6", "3EA7", "3EA2", "3E90", "3E93", "3E99", "3E9C", "3EA1", "9BA5", "9BA8", "3EA4",
"9B21", "9BA0", "9BA2", "9BA4", "9BAA", "9BAB", "9BAC", "87CA", "3EA3", "9B41", "9BC0", "9BC2", "9BC4",
"9BCA", "9BCB", "9BCC", "3E91", "3E92", "3E98", "3E9B", "9BC5", "9BC8", "3E96", "3E9A", "3E94", "9BC6",
"9BE6", "9BF6", "3EA9", "3EA0"],
# Ice Lake
"icllp": ["8A71", "8A56", "8A58", "8A5B", "8A5D", "8A54", "8A5A", "8A5C", "8A57", "8A59", "8A50", "8A51", "8A52",
"8A53"],
# Tiger Lake
"tgllp": ["9A60", "9A68", "9A70", "9A40", "9A49", "9A78", "9AC0", "9AC9", "9AD9", "9AF8"],
# Xe MAX
"dg1": ["4905"],
# Rocket Lake
"Gen11": ["4C8A", "4C8B", "4C90", "4C9A", "4C8C"],
#
"Gen12LP": [],
# Alder Lake
"adls": ["4680", "4682", "4688", "468A", "4690", "4692", "4693"],
# Alder Lake
"aldp": ["4626", "4628", "462A", "46A0", "46A1", "46A2", "46A3", "46A6", "46A8", "46AA", "46B0", "46B1", "46B2",
"46B3", "46C0", "46C1", "46C2", "46C3", "46D0", "46D1", "46D2"],
# # Alchemist
# "": ["5690", "56A0", "5691", "56A1", "5692", "56A5" ,"5693", "5694", "56A6"],
# # Flex Series
# "": ["56C1", "56C0"],
}
intel_arch_to_name_mapping = {
"skl": "Skylake with Intel Processor Graphics Gen9",
"kbl": "Kaby Lake with Intel Processor Graphics Gen9",
"cfl": "Coffee Lake with Intel Processor Graphics Gen9",
"glk": "Gemini Lake with Intel Processor Graphics Gen9",
"icllp": "Ice Lake with Intel Processor Graphics Gen11",
"tgllp": "Tiger Lake with Intel Processor Graphics Gen12",
"dg1": "Intel Iris Xe MAX graphics",
"Gen9": "Intel Processor Graphics Gen9",
"Gen11": "Rocket Lake with Intel Processor Graphics Gen11",
"Gen12LP": "Intel Processor Graphics Gen12 (Lower Power)",
"adls": "Alder Lake S with Intel Processor Graphics Gen12.2",
"aldp": "Alder Lake P with Intel Processor Graphics Gen12.2",
}

# construct PLSSVM_TARGET_PLATFORMS string
plssvm_target_platforms = []
if not args.gpus_only:
Expand Down Expand Up @@ -166,32 +108,22 @@ def cond_print(msg=""):
plssvm_target_platforms.append("amd:" + ",".join(set(amd_gpus)))

# Intel GPU information
intel_gpu_names = []
for device in pylspci.parsers.SimpleParser().run():
if re.search("VGA", str(device.cls), re.IGNORECASE):
for key in intel_arch_mapping:
if any(re.search(arch, str(device.device), re.IGNORECASE) for arch in intel_arch_mapping[key]):
intel_gpu_names.append(str(device.device))
break
intel_num_gpus = len(intel_gpu_names)

if intel_num_gpus>0:
intel_gpus = { x: intel_gpu_names.count(x) for x in intel_gpu_names }
intel_gpu_arch = { }
for name in intel_gpus:
for key in intel_arch_mapping:
if any(re.search(arch, name, re.IGNORECASE) for arch in intel_arch_mapping[key]):
intel_gpu_arch[name] = key
break

cond_print("Found {} Intel (i)GPU(s):".format(intel_num_gpus))
for name in intel_gpus:
cond_print(" {}x {} ({}): {}".format(intel_gpus[name], name,
intel_arch_to_name_mapping[intel_gpu_arch[name]],
intel_gpu_arch[name]))
cond_print()

plssvm_target_platforms.append("intel:" + ",".join({ str(sm) for sm in intel_gpu_arch.values() }))
intel_gpus = []
pci_entry = subprocess.Popen(["lspci -nn | grep -Ei 'VGA|DISPLAY'"], stdout=subprocess.PIPE, shell=True)
(out, err) = pci_entry.communicate()
for vga in str(out).splitlines():
# check if the device is an Intel GPU
if "Intel" in vga:
# extract the architecture hex-value from the lspci line
regex_pattern = r"\[[0-9]+:(.*?)\]"
pci_value = re.search("\[[0-9]+:(.*?)\]", vga)
if pci_value:
value = pci_value.group(1)
intel_gpus.append("0x{}".format(value))

if len(intel_gpus)>0:
cond_print("Found {} Intel GPU(s): [{}]\n".format(len(intel_gpus), ", ".join(intel_gpus)))
plssvm_target_platforms.append("intel:" + ",".join(set(intel_gpus)))

cond_print("Possible -DPLSSVM_TARGET_PLATFORMS entries:")
print(";".join(plssvm_target_platforms))

0 comments on commit 7c02de9

Please sign in to comment.