Skip to content

Commit

Permalink
Refacto.
Browse files Browse the repository at this point in the history
  • Loading branch information
kouchy committed Apr 26, 2024
1 parent 6795891 commit 43ed034
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 284 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ src_files.txt
tests/build*
tests/code_coverage_files/
tests/code_coverage_report/
src/gen/*

build*
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ coverage-linux:
artifacts:
name: code-coverage-report
paths:
- ./code_coverage_report/
- ./tests/code_coverage_report/
script:
- ./ci/coverage-linux.sh

Expand Down
41 changes: 21 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ message(STATUS " * MIPP_TESTS_EXE: '${MIPP_TESTS_EXE}'")
message(STATUS " * MIPP_STATIC_LIB: '${MIPP_STATIC_LIB}'")

set(MIPP_HEADERS
src/mipp.h
src/mipp_impl_AVX512.hxx
src/mipp_impl_AVX.hxx
src/mipp_impl_NEON.hxx
src/mipp_impl_SSE.hxx
src/mipp_object.hxx
src/mipp_scalar_op.h
src/mipp_scalar_op.hxx
include/mipp.h
include/mipp_impl_AVX512.hxx
include/mipp_impl_AVX.hxx
include/mipp_impl_NEON.hxx
include/mipp_impl_SSE.hxx
include/mipp_object.hxx
include/mipp_scalar_op.h
include/mipp_scalar_op.hxx
)

set(MIPP_MATH_HEADERS
src/math/avx512_mathfun.h
src/math/avx512_mathfun.hxx
src/math/avx_mathfun.h
src/math/avx_mathfun.hxx
src/math/neon_mathfun.h
src/math/neon_mathfun.hxx
src/math/sse_mathfun.h
src/math/sse_mathfun.hxx
include/math/avx512_mathfun.h
include/math/avx512_mathfun.hxx
include/math/avx_mathfun.h
include/math/avx_mathfun.hxx
include/math/neon_mathfun.h
include/math/neon_mathfun.hxx
include/math/sse_mathfun.h
include/math/sse_mathfun.hxx
)

if (MIPP_STATIC_LIB)
set(MIPP_SRCS
src/mipp_SSE_LUT.cpp
src/mipp_AVX_LUT.cpp
src/mipp_NEON_LUT.cpp
src/gen/compress_LUT_AVX.cpp
src/gen/compress_LUT_SSE.cpp
src/gen/compress_LUT_NEON.cpp
)
endif()

Expand Down Expand Up @@ -112,7 +112,8 @@ if (MIPP_TESTS_EXE)
set_target_properties(run_tests PROPERTIES OUTPUT_NAME run-tests POSITION_INDEPENDENT_CODE ON) # set -fpie

# include MIPP headers
target_include_directories(run_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/")
target_include_directories(run_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/")

# include Catch2 header
target_include_directories(run_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/tests/lib/Catch2/include/")

Expand Down
67 changes: 35 additions & 32 deletions gencode.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,93 @@
#!/usr/bin/python3
#!/usr/bin/env python3

from jinja2 import Environment, FileSystemLoader
from pathlib import Path
import sys

if sys.version_info[0] != 3 or sys.version_info[1] < 5:
print("This script requires Python version 3.5")
sys.exit(1)

env = Environment(loader = FileSystemLoader("codegen"))
template_lut = env.get_template("vcompress-LUT.cpp.j2")
template_file = env.get_template("mipp_LUT.cpp.j2")


def generate_lut(entries, simdwidth, words_per_simd):
lut = [[0 for j in range(0, simdwidth)] for i in range(0, entries)]

elem_bytes = simdwidth // words_per_simd

for i in range(0, entries):
mask = i
j = 0

for k in range(0, words_per_simd):
for b in range(0, elem_bytes):
lut[i][j + b] = k * elem_bytes + b

if mask & 1 == 1:
j += elem_bytes
mask >>= 1

for k in range(j, simdwidth):
lut[i][k] = -1

return lut

def write_all_luts(filename, all_luts):

def write_all_luts(filename, all_luts):
all_content = template_file.render(
luts = all_luts,
luts = all_luts,
)

with open(filename, "w+") as file:
file.write(all_content)

def generate_luts(filename, simdname, simdwidth, entrydef, lut_params_list):

(entrytype, entrybytes) = entrydef

all_luts = []
for entries, simd_words in lut_params_list:

elem_bits = (simdwidth // simd_words) * entrybytes * 8

lut = template_lut.render(
lutname = f"vcompress_LUT{elem_bits}x{simd_words}_{simdname}",
entries = entries,
simdwidth = simdwidth,
entrytype = entrytype,
entrytype = entrytype,
lut = generate_lut(entries, simdwidth, simd_words)
)

all_luts += [lut]

write_all_luts(filename, all_luts)



def generate_AVX_luts(filename):

lut_AVX_32x8 = template_lut.render(
lutname = f"vcompress_LUT32x8_AVX",
entries = 256,
simdwidth = 8,
entrytype = "int32_t",
lut = generate_lut(256, 8, 8)
lutname = f"vcompress_LUT32x8_AVX",
entries = 256,
simdwidth = 8,
entrytype = "int32_t",
lut = generate_lut(256, 8, 8)
)

lut_AVX_64x4 = template_lut.render(
lutname = "vcompress_LUT64x4_AVX",
entries = 16,
simdwidth = 8,
entrytype = "int32_t",
lut = generate_lut(16, 8, 4)
lutname = "vcompress_LUT64x4_AVX",
entries = 16,
simdwidth = 8,
entrytype = "int32_t",
lut = generate_lut(16, 8, 4)
)

all_luts = [lut_AVX_32x8, lut_AVX_64x4]

write_all_luts(filename, all_luts)
pass

generate_luts("src/mipp_SSE_LUT.cpp", "SSE", 16, ("int8_t", 1), [(4, 2), (16, 4), (256, 8), (65536, 16)])
generate_luts("src/mipp_NEON_LUT.cpp", "NEON", 16, ("int8_t", 1), [(4, 2), (16, 4), (256, 8), (65536, 16)])

#generate_luts("src/mipp_AVX_LUT.cpp", "AVX", 8, ("int32_t", 4), [(256, 8)])
generate_AVX_luts("src/mipp_AVX_LUT.cpp")
Path("src/gen").mkdir(parents=True, exist_ok=True)

generate_luts("src/gen/compress_LUT_SSE.cpp", "SSE", 16, ("int8_t", 1), [(4, 2), (16, 4), (256, 8), (65536, 16)])
generate_luts("src/gen/compress_LUT_NEON.cpp", "NEON", 16, ("int8_t", 1), [(4, 2), (16, 4), (256, 8), (65536, 16)])

#generate_luts("src/gen/mipp_compress_LUT_AVX.cpp", "AVX", 8, ("int32_t", 4), [(256, 8)])
generate_AVX_luts("src/gen/compress_LUT_AVX.cpp")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
71 changes: 0 additions & 71 deletions tests/CMakeLists.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/cmake/compiler_warnings.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions tests/cmake/target_fast_math.cmake

This file was deleted.

Loading

0 comments on commit 43ed034

Please sign in to comment.