diff --git a/README.md b/README.md index 82795a45929..1c8d0211682 100644 --- a/README.md +++ b/README.md @@ -65,17 +65,17 @@ Supported Compilers This library uses C++17 (or newer when available). -| Accelerator Back-end | gcc 9.5
(Linux) | gcc 10.4 / 11.1
(Linux) | gcc 12.3
(Linux) | gcc 13.1
(Linux) | clang 9
(Linux) | clang 10 / 11
(Linux) | clang 12
(Linux) | clang 13
(Linux) | clang 14
(Linux) | clang 15
(Linux) | clang 16
(Linux) | clang 17
(Linux) | icpx 2024.2 (Linux) | Xcode 13.2.1 / 14.2 / 14.3.1
(macOS) | Visual Studio 2022
(Windows) | -|--------------------------------------------------------------------------------|-------------------------------------------------|-------------------------------------------------|---------------------------------------------|------------------------|------------------------------------------------------------|-------------------------------------------------------|-------------------------------------------------|---------------------------------------------|---------------------------------------------------|-------------------------------------------|-------------------------------------------|-------------------------------------------|----------------------------------|-------------------------------------------------------|--------------------------------------| -| Serial | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| OpenMP 2.0+ blocks | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:[^3] | :white_check_mark: | :white_check_mark: | -| OpenMP 2.0+ threads | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:[^3] | :white_check_mark: | :white_check_mark: | -| std::thread | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| TBB | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| CUDA (nvcc) | :white_check_mark:
(CUDA 11.2 - 12.5)[^2] | :white_check_mark:
(CUDA 11.4 - 12.0)[^2] | :white_check_mark:
(CUDA 12.0 - 12.5) | :white_check_mark:
(CUDA 12.4 - 12.5) | :white_check_mark:
(11.6 - 12.0)[^2] | :white_check_mark:
(CUDA 11.2, 11.6 - 12.0)[^2] | :white_check_mark:
(CUDA 11.6 - 12.0)[^2] | :white_check_mark:
(CUDA 11.7 - 12.0) | :white_check_mark:
(CUDA 11.8 - 12.0) | :white_check_mark:
(CUDA 12.2) | :white_check_mark:
(CUDA 12.3) | :white_check_mark:
(CUDA 12.4 - 12.5) | :x: | :x: | :x: | -| CUDA (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (CUDA 11.2 - 11.5) | :white_check_mark: (CUDA 11.2 - 11.5)[^1] | :white_check_mark: (CUDA 11.2 - 11.5)[^1] | :white_check_mark: (CUDA 11.2 - 11.8)[^1] | :x: | - | - | -| [HIP](https://alpaka.readthedocs.io/en/latest/install/HIP.html) (clang) | - | - | - | :x: | :x: | :x: | :x: | :x: | :white_check_mark: (HIP 5.1 - 5.2) | :white_check_mark: (HIP 5.3 - 5.4) | :white_check_mark: (HIP 5.5 - 5.6) | :white_check_mark: (HIP 5.7 - 6.0) | :x: | - | - | -| SYCL | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark:[^4] | :x: | :x: | +| Accelerator Back-end | gcc 9.5 (Linux) | gcc 10.4 / 11.1 (Linux) | gcc 12.3 (Linux) | gcc 13.1 (Linux) | clang 9 (Linux) | clang 10/11 (Linux) | clang 12 (Linux) | clang 13 (Linux) | clang 14 (Linux) | clang 15 (Linux) | clang 16 (Linux) | clang 17 (Linux) | icpx 2024.2 (Linux) | Xcode 13.2.1 / 14.2 / 14.3.1 (macOS) | Visual Studio 2022 (Windows) | +|----------------------|-------------------------------------------|-------------------------------------------|---------------------------------------|---------------------------------------|-------------------------------------------|-------------------------------------------------|-------------------------------------------|---------------------------------------|---------------------------------------|---------------------------------------|---------------------------------------|---------------------------------------|-------------------------|--------------------------------------|------------------------------| +| Serial | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| OpenMP 2.0+ blocks | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: [^1] | :white_check_mark: | :white_check_mark: | +| OpenMP 2.0+ threads | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: [^1] | :white_check_mark: | :white_check_mark: | +| std::thread | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| TBB | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| CUDA (nvcc) | :white_check_mark: (CUDA 11.2 - 12.5)[^2] | :white_check_mark: (CUDA 11.4 - 12.0)[^2] | :white_check_mark: (CUDA 12.0 - 12.5) | :white_check_mark: (CUDA 12.4 - 12.5) | :white_check_mark: (CUDA 11.6 - 12.0)[^2] | :white_check_mark: (CUDA 11.2, 11.6 - 12.0)[^2] | :white_check_mark: (CUDA 11.6 - 12.0)[^2] | :white_check_mark: (CUDA 11.7 - 12.0) | :white_check_mark: (CUDA 11.8 - 12.0) | :white_check_mark: (CUDA 12.2) | :white_check_mark: (CUDA 12.3) | :white_check_mark: (CUDA 12.4 - 15.5) | :x: | - | :x: | +| CUDA (clang) | - | - | - | - | :x: | :x: | :x: | :x: | :white_check_mark: (CUDA 11.2 - 11.5) | :white_check_mark: (CUDA 11.2 - 11.5) | :white_check_mark: (CUDA 11.2 - 11.5) | :white_check_mark: (CUDA 11.2 - 11.8) | :x: | - | - | +| HIP (clang) | - | - | - | - | :x: | :x: | :x: | :x: | :white_check_mark: (HIP 5.1 - 5.2) | :white_check_mark: (HIP 5.3 - 5.4) | :white_check_mark: (HIP 5.5 - 5.6) | :white_check_mark: (HIP 5.7 - 6.1) | :x: | - | - | +| SYCL | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: [^4] | - | :x: | Other compilers or combinations marked with :x: in the table above may work but are not tested in CI and are therefore not explicitly supported. diff --git a/script/readme_generator/README.md b/script/readme_generator/README.md new file mode 100644 index 00000000000..9a755074a1f --- /dev/null +++ b/script/readme_generator/README.md @@ -0,0 +1,13 @@ +# About + +The script generates the Markdown table for compiler compatibility for back-ends for the alpaka `README.md`. It reads the properties from the `supported_compiler.json` and outputs the Markdown table to stdout. + +```bash +./generate_supported_compilers.py +``` + +The generated Markdown can be copied to the alpaka `README.md`. + +# Configuration File + +The configuration file contains a dictionary. Each key in the dictionary is a compiler. The values contain information about the compatibility with the back-ends. The names of the back-ends are specified by the script. Each back-end requires a `state` property. The `comment` property is optional. diff --git a/script/readme_generator/generate_supported_compilers.py b/script/readme_generator/generate_supported_compilers.py new file mode 100755 index 00000000000..7ebeed01712 --- /dev/null +++ b/script/readme_generator/generate_supported_compilers.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python3 + +import os +import sys +import json +from typing import List, Dict +from dataclasses import dataclass + + +def print_red(msg: str): + """print message with color red""" + print("\033[0;31m" + msg + "\033[0m") + + +@dataclass +class ConfigEntry: + """Stores the key for the json config and how the key is printed in + markdown. + """ + + name: str + representation: str + + +# pylint: disable=missing-docstring +def get_expected_config_entries() -> List[ConfigEntry]: + return [ + ConfigEntry("serial", "Serial"), + ConfigEntry("OMPblock", "OpenMP 2.0+ blocks"), + ConfigEntry("OMPthread", "OpenMP 2.0+ threads"), + ConfigEntry("thread", "std::thread"), + ConfigEntry("tbb", "TBB"), + ConfigEntry("CUDAnvcc", "CUDA (nvcc)"), + ConfigEntry("CUDAclang", "CUDA (clang)"), + ConfigEntry("hip", "HIP (clang)"), + ConfigEntry("sycl", "SYCL"), + ] + + +# pylint: disable=missing-docstring +def get_expected_config_names() -> List[str]: + return [n.name for n in get_expected_config_entries()] + + +def get_known_states() -> Dict[str, str]: + """Returns a dict of known backend states. The key is the value in the + config json and the value how it will be printed in markdown. + """ + return {"yes": ":white_check_mark:", "no": ":x:", "none": "-"} + + +# pylint: disable=missing-docstring +def get_known_state_names() -> List[str]: + return list(get_known_states().keys()) + + +def config_validator(conf: Dict[str, Dict[str, str]]) -> bool: + """Validate the json configuration and prints errors.""" + for compiler_name, compiler_conf in conf.items(): + for expected_entry in get_expected_config_names(): + if expected_entry not in compiler_conf: + print_red(f"[ERROR]: {compiler_name} misses entry {expected_entry}") + return False + if "state" not in compiler_conf[expected_entry]: + print_red( + f"[ERROR]: {compiler_name}/{expected_entry} misses state entry" + ) + return False + if compiler_conf[expected_entry]["state"] not in get_known_state_names(): + print_red( + f"[ERROR]: {compiler_name}/{expected_entry}/state " + f"unknown state: {compiler_conf[expected_entry]['state']}" + ) + return False + + return True + + +def render_table(conf): + """Renders the configuration to a markdown table""" + # [column][row] + table: List[List[str]] = [] + + # add backend names + backends: List[str] = ["Accelerator Back-end"] + for config_entry in get_expected_config_entries(): + backends.append(config_entry.representation) + table.append(backends) + + # reads the state of each backend for each compiler and generates the cell + # the cell contains at least a symbol for the state and can also contains + # a comment + for compiler_name, compiler_conf in conf.items(): + column: List[str] = [compiler_name] + for backend in compiler_conf.values(): + value = get_known_states()[backend["state"]] + if "comment" in backend: + value += f" {backend['comment']}" + column.append(value) + table.append(column) + + # each cell in a column should have the same width + # therefore determine the broadest cell in a column + column_sizes: List[int] = [] + for col in table: + size = 0 + for row in col: + size = max(size, len(row)) + column_sizes.append(size) + + # print the table header + print("|", end="") + for c_num in range(len(table)): + print(f" {table[c_num][0]:<{column_sizes[c_num]}} |", end="") + print() + + # print the lines under the table header + print("|", end="") + for c_num in range(len(table)): + print((column_sizes[c_num] + 2) * "-" + "|", end="") + print() + + # prints each backend state cell for each compiler + for r_num in range(1, len(table[0])): + print("|", end="") + for c_num in range(len(table)): + print(f" {table[c_num][r_num]:<{column_sizes[c_num]}} |", end="") + print() + + +if __name__ == "__main__": + script_path = os.path.dirname(os.path.realpath(__file__)) + config_path = os.path.join(script_path, "supported_compilers.json") + + if not os.path.exists(config_path): + print_red(f"[ERROR]: {config_path} does not exist") + sys.exit(1) + + with open(config_path, "r", encoding="utf-8") as config_file: + config = json.load(config_file) + + if not config_validator(config): + sys.exit(1) + + render_table(config) diff --git a/script/readme_generator/supported_compilers.json b/script/readme_generator/supported_compilers.json new file mode 100644 index 00000000000..0a929950263 --- /dev/null +++ b/script/readme_generator/supported_compilers.json @@ -0,0 +1,460 @@ +{ + "gcc 9.5 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.2 - 12.5)[^2]" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "no" + } + }, + "gcc 10.4 / 11.1 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.4 - 12.0)[^2]" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "no" + } + }, + "gcc 12.3 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 12.0 - 12.5)" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "no" + } + }, + "gcc 13.1 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 12.4 - 12.5)" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "no" + } + }, + "clang 9 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.6 - 12.0)[^2]" + }, + "CUDAclang": { + "state": "no" + }, + "hip": { + "state": "no" + }, + "sycl": { + "state": "no" + } + }, + "clang 10/11 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.2, 11.6 - 12.0)[^2]" + }, + "CUDAclang": { + "state": "no" + }, + "hip": { + "state": "no" + }, + "sycl": { + "state": "no" + } + }, + "clang 12 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.6 - 12.0)[^2]" + }, + "CUDAclang": { + "state": "no" + }, + "hip": { + "state": "no" + }, + "sycl": { + "state": "no" + } + }, + "clang 13 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.7 - 12.0)" + }, + "CUDAclang": { + "state": "no" + }, + "hip": { + "state": "no" + }, + "sycl": { + "state": "no" + } + }, + "clang 14 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 11.8 - 12.0)" + }, + "CUDAclang": { + "state": "yes", + "comment": "(CUDA 11.2 - 11.5)" + }, + "hip": { + "state": "yes", + "comment": "(HIP 5.1 - 5.2)" + }, + "sycl": { + "state": "no" + } + }, + "clang 15 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 12.2)" + }, + "CUDAclang": { + "state": "yes", + "comment": "(CUDA 11.2 - 11.5)" + }, + "hip": { + "state": "yes", + "comment": "(HIP 5.3 - 5.4)" + }, + "sycl": { + "state": "no" + } + }, + "clang 16 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 12.3)" + }, + "CUDAclang": { + "state": "yes", + "comment": "(CUDA 11.2 - 11.5)" + }, + "hip": { + "state": "yes", + "comment": "(HIP 5.5 - 5.6)" + }, + "sycl": { + "state": "no" + } + }, + "clang 17 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "yes", + "comment": "(CUDA 12.4 - 15.5)" + }, + "CUDAclang": { + "state": "yes", + "comment": "(CUDA 11.2 - 11.8)" + }, + "hip": { + "state": "yes", + "comment": "(HIP 5.7 - 6.1)" + }, + "sycl": { + "state": "no" + } + }, + "icpx 2024.2 (Linux)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes", + "comment": "[^1]" + }, + "OMPthread": { + "state": "yes", + "comment": "[^1]" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "no" + }, + "CUDAclang": { + "state": "no" + }, + "hip": { + "state": "no" + }, + "sycl": { + "state": "yes", + "comment": "[^4]" + } + }, + "Xcode 13.2.1 / 14.2 / 14.3.1 (macOS)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "none" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "none" + } + }, + "Visual Studio 2022 (Windows)": { + "serial": { + "state": "yes" + }, + "OMPblock": { + "state": "yes" + }, + "OMPthread": { + "state": "yes" + }, + "thread": { + "state": "yes" + }, + "tbb": { + "state": "yes" + }, + "CUDAnvcc": { + "state": "no" + }, + "CUDAclang": { + "state": "none" + }, + "hip": { + "state": "none" + }, + "sycl": { + "state": "no" + } + } +}