Skip to content

Commit d2993f5

Browse files
committed
Many smaller changes for testing
Add better output templating Add better pytest reporting Add more settings Fix float16 validation for Inf and -Inf Add all timestamp types support Changed Combination1 test to include all timestamps
1 parent cad8de6 commit d2993f5

21 files changed

+375
-212
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,4 @@ cmake-build-*/
498498
*.fbs
499499
**/fletcherfiltering_test_workspace/**
500500
**/mysql-data/**
501+
vivado-projects/**

.idea/sqldialects.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

run-pytest.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source activate FletcherFiltering
44

5-
PYTHONPATH="$PYTHONPATH:`pwd`/src:`pwd`/../transpyle:`pwd`/../fletcher/codegen:`pwd`/../moz-sql-parser" python -m pytest -s --show-progress --print-relative-time --verbose --cov=fletcherfiltering "$@" tests/
5+
PYTHONPATH="$PYTHONPATH:`pwd`/src:`pwd`/../transpyle:`pwd`/../fletcher/codegen:`pwd`/../moz-sql-parser" python -m pytest -rxXs --show-progress --print-relative-time --verbose --cov=fletcherfiltering "$@" tests/

run_pytest.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ conda activate FletcherFiltering
66
$pwd = Get-Location
77
$env:PYTHONPATH ="$pwd\src;$pwd\..\transpyle;$pwd\..\fletcher\codegen;$pwd\..\moz-sql-parser"
88

9-
python -m pytest -s --show-progress --print-relative-time --verbose --cov=fletcherfiltering @Passthrough tests/
9+
python -m pytest -rxXs --show-progress --print-relative-time --verbose --cov=fletcherfiltering @Passthrough tests/

src/fletcherfiltering/codegen/compiler.py

+34-24
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from .transformations.ConstantPropagationTransform import ConstantPropagationTransform
2525
from .transformations.PythonASTTransform import PythonASTTransform
2626

27+
from collections import namedtuple
28+
2729
# These templates are all formatted, so double up curly braces.
2830
source_header_header = """#pragma once
2931
#if _MSC_VER && !__INTEL_COMPILER
@@ -48,6 +50,8 @@
4850

4951
source_header_test_footer = """}}"""
5052

53+
TemplateData = namedtuple('TemplateData', ['source', 'destination'])
54+
5155

5256
class Compiler(object):
5357
def __init__(self, in_schema: pa.Schema, out_schema: pa.Schema):
@@ -75,7 +79,7 @@ def __call__(self, query_str: str, output_dir: Path = Path('.'), query_name: str
7579
include_build_system: bool = True, include_test_system: bool = True,
7680
extra_include_dirs: List[PurePath] = '',
7781
extra_link_dirs: List[PurePath] = '',
78-
extra_link_libraries: List[str] = '', part_name: str = 'xa7a12tcsg325-1q'):
82+
extra_link_libraries: List[str] = '', part_name: str = settings.PART_NAME):
7983
assert isinstance(query_str, str)
8084

8185
queries = self.parse(query_str)
@@ -100,6 +104,7 @@ def __call__(self, query_str: str, output_dir: Path = Path('.'), query_name: str
100104
out_str_columns = [x.name for x in self.out_schema if x.type == pa.string()]
101105

102106
template_data = {
107+
'VAR_LENGTH': settings.VAR_LENGTH,
103108
'query_name': query_name,
104109
'generated_files': " ".join(generated_files),
105110
'extra_include_dirs': ' '.join([d.as_posix() for d in extra_include_dirs]),
@@ -113,32 +118,37 @@ def __call__(self, query_str: str, output_dir: Path = Path('.'), query_name: str
113118
'out_columns_tb_new': "\n ".join([tb_new.format(x, settings.VAR_LENGTH + 1) for x in out_str_columns]),
114119
}
115120

116-
if include_build_system:
117-
self.copy_files(self.template_path, output_dir.resolve(),
118-
[Path('fletcherfiltering.cpp'), Path('fletcherfiltering.h')])
121+
build_system_files = [
122+
TemplateData(self.template_path / Path('template.fletcherfiltering.cpp'),
123+
output_dir / Path('fletcherfiltering.cpp')),
124+
TemplateData(self.template_path / Path('template.fletcherfiltering.h'),
125+
output_dir / Path('fletcherfiltering.h')),
126+
TemplateData(self.template_path / Path('template.CMakeLists.txt'),
127+
output_dir / Path('CMakeLists.txt')),
128+
]
129+
130+
test_system_files = [
131+
TemplateData(self.template_path / Path('template.run_complete_hls.tcl'),
132+
output_dir / Path('run_complete_hls.tcl')),
133+
TemplateData(self.template_path / Path('template.testbench.cpp'),
134+
output_dir / Path('{0}{1}.cpp'.format(query_name, settings.TESTBENCH_SUFFIX))),
135+
TemplateData(self.template_path / Path('template.data.h'),
136+
output_dir / Path('{0}{1}.h'.format(query_name, settings.DATA_SUFFIX))),
137+
]
119138

120-
with open(self.template_path / 'template.CMakeLists.txt', 'r') as template_file:
121-
cmake_list = string.Template(template_file.read())
122-
with open(output_dir / Path('CMakeLists.txt'), 'w') as cmake_file:
123-
cmake_file.write(cmake_list.safe_substitute(template_data))
139+
if include_build_system:
140+
for file in build_system_files:
141+
with open(file.source, 'r') as template_file:
142+
output_data = string.Template(template_file.read())
143+
with open(file.destination, 'w') as output_file:
144+
output_file.write(output_data.safe_substitute(template_data))
124145

125146
if include_test_system:
126-
with open(self.template_path / 'template.run_complete_hls.tcl', 'r') as template_file:
127-
hls_tcl = string.Template(template_file.read())
128-
with open(output_dir / Path('run_complete_hls.tcl'), 'w') as hls_tcl_file:
129-
hls_tcl_file.write(hls_tcl.safe_substitute(template_data))
130-
131-
with open(self.template_path / 'template.testbench.cpp', 'r') as template_file:
132-
teshbench_cpp = string.Template(template_file.read())
133-
with open(output_dir / Path('{0}{1}.cpp'.format(query_name, settings.TESTBENCH_SUFFIX)),
134-
'w') as teshbench_cpp_file:
135-
teshbench_cpp_file.write(teshbench_cpp.safe_substitute(template_data))
136-
137-
with open(self.template_path / 'template.data.h', 'r') as template_file:
138-
data_cpp = string.Template(template_file.read())
139-
with open(output_dir / Path('{0}{1}.h'.format(query_name, settings.DATA_SUFFIX)),
140-
'w') as data_cpp_file:
141-
data_cpp_file.write(data_cpp.safe_substitute(template_data))
147+
for file in test_system_files:
148+
with open(file.source, 'r') as template_file:
149+
output_data = string.Template(template_file.read())
150+
with open(file.destination, 'w') as output_file:
151+
output_file.write(output_data.safe_substitute(template_data))
142152

143153
def copy_files(self, source_dir: PurePath, output_dir: PurePath, file_list: List[Path]):
144154
if source_dir == output_dir:

src/fletcherfiltering/codegen/templates/fletcherfiltering.cpp src/fletcherfiltering/codegen/templates/template.fletcherfiltering.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ bool __sql_builtin_like(char* data, int len, const char* pattern_name){
66
}
77

88
void __sql_builtin_concat(char* buffer, int* offset, const char* value, int length){
9-
for(int i = 0; i < length && *offset < STRING_SIZE; i++, (*offset)++){
10-
buffer[*offset] = value[i];
9+
for(int i = 0, j = *offset; i < length && j < VAR_LENGTH; i++, (j)++){
10+
#pragma HLS PIPELINE II=1
11+
buffer[j] = value[i];
1112
}
13+
*offset += length;
1214
buffer[*offset] = '\0';
1315
}

src/fletcherfiltering/codegen/templates/fletcherfiltering.h src/fletcherfiltering/codegen/templates/template.fletcherfiltering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22
#include <inttypes.h>
3-
#define STRING_SIZE 255
3+
#define VAR_LENGTH ${VAR_LENGTH}
44

55
template <typename T>
66
struct nullable {

src/fletcherfiltering/codegen/templates/template.run_complete_hls.tcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ set_part {${part_name}}
1616
create_clock -period 10 -name default
1717
csim_design -O
1818
csynth_design
19-
cosim_design -trace_level all -rtl vhdl
19+
cosim_design -O -trace_level all -rtl vhdl
2020
#export_design -rtl vhdl -format ip_catalog
2121
exit

0 commit comments

Comments
 (0)