Skip to content

Commit

Permalink
Merge pull request #71 from db-tu-dresden/primitive_table_vis
Browse files Browse the repository at this point in the history
Added call signature
  • Loading branch information
alexKrauseTUD authored Oct 13, 2023
2 parents 7849c41 + a917757 commit 00c58f0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upload_indexhtml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
id: generate
continue-on-error: true
run: |
python main.py --print-outputs-only
python main.py --print-outputs-only --copy-additional-www-files
- name: Show path
run: |
echo ${{ github.workspace }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: sans-serif;}
.checkmark {
display: inline-block;
transform: rotate(45deg);
height: 12px;
width: 5px;
border-bottom: 6px solid #78b13f;
border-right: 5px solid #78b13f;
}
.dot_yes {
height: 25px;
width: 25px;
background-color: rgb(51, 208, 51);
border-radius: 50%;
display: inline-block;
}
.dot_no {
height: 25px;
width: 25px;
background-color: rgb(187, 40, 40);
border-radius: 50%;
display: inline-block;
}
.avail {
color: rgb(51, 208, 51);
font-weight: bolder;
Expand Down
8 changes: 6 additions & 2 deletions generator/core/model/tsl_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from copy import deepcopy
from pathlib import Path
from typing import Set, List
from typing import Set, List, Tuple

from generator.core.tsl_config import config
from generator.utils.log_utils import LogInit
Expand All @@ -25,6 +25,10 @@ def data(self) -> YamlDataType:
def name(self) -> str:
return self.__data_dict["extension_name"]

@property
def sort_keys(self) -> Tuple[str, int, str]:
return (self.__data_dict["vendor"], int(self.__data_dict["simdT_default_size_in_bits"]), self.__data_dict["extension_name"])

@property
def file_name(self) -> Path:
return self.__file_path
Expand Down Expand Up @@ -76,7 +80,7 @@ def __init__(self) -> None:

@property
def known_extensions(self) -> List[str]:
return sorted([extension.name for extension in self.__extensions])
return [extension.name for extension in sorted([extension for extension in self.__extensions], key=lambda extension: extension.sort_keys)]

@requirement(extension="NotNone")
def add_extension(self, extension: TSLExtension, logLevel=logging.INFO) -> None:
Expand Down
18 changes: 15 additions & 3 deletions parseForPrimitiveTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import sys
import shutil
import html
from typing import List

from generator.core.tsl_config import config, parse_args
Expand All @@ -12,18 +13,22 @@
from generator.core.ctrl.tsl_lib import TSLLib

class PrintablePrimitive:
def __init__(self, name: str, description: str, ctype_to_extension_dict: dict ) -> None:
def __init__(self, name: str, description: str, ctype_to_extension_dict: dict, vec_type: List[str], parameters: List[str], return_type: str) -> None:
self.name = name
self.description = description
self.ctype_to_extension_dict = ctype_to_extension_dict
self.vec_type = vec_type
self.parameters = parameters
self.return_type = return_type
pass

def __repr__(self) -> str:
return f"{self.name}: {self.ctype_to_extension_dict}"

def to_html(self, considered_types: list, considered_exts: list) -> str:
call_signature = f"{self.name}&lt;{', '.join(self.vec_type)}&gt;({', '.join(self.parameters)}) -> {self.return_type}"
primitive_button = f"""<div class="primitiveContainer"><div class="primitive"><button id ="{self.name}_link" onclick="togglePrimitive(event, '{self.name}')">{self.name}</button></div>"""
primitive_table_start = f"""<div id="{self.name}" class="primitiveinfo"><p>Brief: <span class="description">{self.description}</span></p><center><table border=1 cellpadding=10 cellspacing=0>"""
primitive_table_start = f"""<div id="{self.name}" class="primitiveinfo"><p>Brief: <span class="description">{self.description}</span></p><p>Call signature: <br><code>{call_signature}</code></p><center><table border=1 cellpadding=10 cellspacing=0>"""
primitive_table_end = """</table></center></div><br/></div>"""

top_left_corner = """<td style="border-top:0;border-left:0;"></td>"""
Expand Down Expand Up @@ -118,7 +123,14 @@ def create_primitive_index_html(tsl_lib: TSLLib) -> None:
for target_extension, ctype_list in primitive.specialization_dict().items():
for ctype in ctype_list:
ctype_ext_dict[ctype].add(target_extension)
pP = PrintablePrimitive(name, brief_description, ctype_ext_dict)

vnames = [primitive.declaration.data["vector_name"]]
if primitive.declaration.data["additional_simd_template_parameter"]['name'] != "":
vnames.append(primitive.declaration.data["additional_simd_template_parameter"]['name'])
pP = PrintablePrimitive(name, brief_description, ctype_ext_dict,
vnames,
[f"{html.escape(param['ctype'])} {param['name']}" for param in primitive.declaration.data["parameters"]],
html.escape(primitive.declaration.data['returns']['ctype']))
primitive_html += pP.to_html(all_types, all_extensions)
primitive_html += f"""</div>"""
html_content = html_content.replace("---filterBoxes---",checkbox_html)
Expand Down
2 changes: 1 addition & 1 deletion primitive_data/primitives/binary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ definitions:
...
---
primitive_name: "binary_or"
brief_description: "Binary ANDs two vector registers."
brief_description: "Binary ORs two vector registers."
parameters:
- ctype: "const typename Vec::register_type"
name: "a"
Expand Down

0 comments on commit 00c58f0

Please sign in to comment.