Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some primitives, fixed some bugs #111

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b6e4d03
added vector compress
JPietrzykTUD Aug 22, 2024
300ad7c
fixed missing return statement in compress
JPietrzykTUD Aug 23, 2024
9c4dbe9
added masked compare_as_imask
JPietrzykTUD Aug 23, 2024
ca1130d
changed avx512vbmi2 to avx512_vbmi2 in lscpu_flags
JPietrzykTUD Aug 23, 2024
b502e50
changed signature of mask_equal_as_imask to get an imask instand of a…
JPietrzykTUD Aug 23, 2024
d66ccdc
added vector compress
JPietrzykTUD Aug 22, 2024
efb69fc
fixed missing return statement in compress
JPietrzykTUD Aug 23, 2024
c109404
added masked compare_as_imask
JPietrzykTUD Aug 23, 2024
58cbada
changed avx512vbmi2 to avx512_vbmi2 in lscpu_flags
JPietrzykTUD Aug 23, 2024
7678206
changed signature of mask_equal_as_imask to get an imask instand of a…
JPietrzykTUD Aug 23, 2024
1771a1e
Merge branch 'experimental' of github.com:db-tu-dresden/TSL into expe…
JPietrzykTUD Sep 13, 2024
5037377
Added popcnt
JPietrzykTUD Sep 19, 2024
c7f8228
Fixed typo for popcount (neon)
JPietrzykTUD Sep 19, 2024
d504b68
Fixed std::popcount usage
JPietrzykTUD Sep 19, 2024
6b928a6
added capability to have multiple overloads with proper ambiguity check
JPietrzykTUD Sep 23, 2024
e5aad2d
lint + flags fix for to_mask (sse)
JPietrzykTUD Sep 23, 2024
70ff23d
fixed redefinition check
JPietrzykTUD Sep 24, 2024
5f05144
fixed potential segfault through to_array
JPietrzykTUD Sep 24, 2024
a9a03a0
fixed neon imask_storeu
JPietrzykTUD Sep 24, 2024
3ea50c6
added popcnt for smaller datatypes
JPietrzykTUD Sep 24, 2024
7f78cc9
fixed typo
JPietrzykTUD Nov 14, 2024
9ac333e
added crazy-max ghaction-setup-docker to build-and-test.yml to enable…
JPietrzykTUD Nov 14, 2024
2cc8b2f
added install-qemu to arm build
JPietrzykTUD Nov 14, 2024
3f767c8
Added binary_mask_and for avx512
JPietrzykTUD Nov 25, 2024
f90c280
fixed kand for avx512
JPietrzykTUD Nov 25, 2024
b3e3b41
Added specific named output in tsl::type_name for cstdint types
alexKrauseTUD Dec 16, 2024
1089e3a
Added mask_sub
JPietrzykTUD Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
requirement-file: "requirements.txt"
docker-tag: "${{ vars.BUILD_TEST_ARM_TAG }}"
context: ".github/actions/tsl-test-arm"
install-qemu: true
platforms: linux/amd64,linux/arm64
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKER_HUB_USER }}
Expand Down Expand Up @@ -222,6 +223,16 @@ jobs:
with:
name: generate_tsl_arm_${{ matrix.tsl_folders }}
path: ${{ github.workspace }}/generate/${{ matrix.tsl_folders }}
# - name: Set up Docker
# uses: crazy-max/ghaction-setup-docker@v3
# with:
# daemon-config: |
# {
# "debug": true,
# "features": {
# "containerd-snapshotter": true
# }
# }
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ template<
{{ ns.full_qualified_parameters_str }}
) -> std::enable_if_t<
{% if functor_name == primitive_name %}
tsl_functor_defined<{{ tsl_implementation_namespace }}::{{ functor_name }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>>::value,
tsl_functor_available<{{ tsl_implementation_namespace }}::{{ functor_name }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>>::value,
{{ returns['ctype'] }}
{% else %}
#ifdef {{ tsl_namespace|upper ~ '_' ~ tsl_implementation_namespace|upper ~ '_' ~ primitive_name|upper ~ '_STRUCT_DEFINED'}}
!tsl_primitive_ambiguous<{{ tsl_implementation_namespace }}::{{ primitive_name }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>, {{ tsl_implementation_namespace }}::{{ functor_name }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>>(),
(
{% for overload in previous_overloads %}
#ifdef {{ tsl_namespace|upper ~ '_' ~ tsl_implementation_namespace|upper ~ '_' ~ overload|upper ~ '_STRUCT_DEFINED'}}
!tsl_primitives_redeclared_v<{{ tsl_implementation_namespace }}::{{ overload }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>, {{ tsl_implementation_namespace }}::{{ functor_name }}<{{ vector_name }}, {{ ns.additional_template_name }}{{ idof_name }}>> {{ '&&' if not loop.last else ""}}
#else
true,
true {{ '&&' if not loop.last else ""}}
#endif
{% endfor %}
),
{{ returns['ctype'] }}
{% endif %}
>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ namespace {{ tsl_implementation_namespace }} {
{# If the vector_length_bits is specified in the yaml file, a specialization is generated. #}
struct {{ functor_name }}<{{ ns.full_extension_name }}, {{ ns.return_template_type }}{{ ns.additional_template_params }}{{ idof_name }}> {
using {{ vector_name }} = {{ ns.full_extension_name }};
{{ 'using gets_parameter_pack = std::true_type;' if ns.contains_parameter_pack else '' }}
{{ ns.using_return_type }}
using return_type = {{ returns['ctype'] }};
{% if ns.has_parameters_tuple %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target_sources({{ tsl_lib_name }}
{% endfor %}
)
target_include_directories({{ tsl_lib_name }} INTERFACE {{ library_root_path }})
target_compile_options({{ tsl_lib_name }} INTERFACE {{ tsl_target_compile_options }})
target_compile_options({{ tsl_lib_name }} INTERFACE {{ tsl_target_compile_options }})# -Wfatal-errors)
{% if use_concepts %}
target_compile_definitions({{ tsl_lib_name }} INTERFACE TSL_USE_CONCEPTS)
{% endif %}
Expand Down
20 changes: 20 additions & 0 deletions generator/core/ctrl/tsl_libfile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from pathlib import Path
from typing import Generator
from itertools import combinations

from jinja2 import Template

Expand Down Expand Up @@ -86,8 +87,27 @@ def __create_primitive_header_files(self, extension_set: TSLExtensionSet,
primitive_class.data)

definition_files_per_extension_dict: Dict[str, TSLHeaderFile] = dict()

#get all declarations and there overloads
primitive_with_overloads_dict = {}
for primitive in primitive_class:
if primitive.declaration.name not in primitive_with_overloads_dict:
primitive_with_overloads_dict[primitive.declaration.name] = [primitive.declaration.name]
if primitive.declaration.name != primitive.declaration.functor_name:
primitive_with_overloads_dict[primitive.declaration.name].append(primitive.declaration.functor_name)

previous_declarations_dict = {}
for _,v in primitive_with_overloads_dict.items():
if len(v) > 1:
for i in range(1, len(v)):
previous_declarations_dict[v[i]] = v[:i]
# for k, v in previous_declarations_dict.items():
# print(f"Previous overload for {k}: {v}")

for primitive in primitive_class:
declaration_data = copy.deepcopy(primitive.declaration.data)
if primitive.declaration.functor_name in previous_declarations_dict:
declaration_data["previous_overloads"] = previous_declarations_dict[primitive.declaration.functor_name]
declaration_data["tsl_function_doxygen"] = config.get_template("core::doxygen_function").render(
declaration_data)
declaration_file.add_code(
Expand Down
16 changes: 16 additions & 0 deletions generator/static_files/core/utils/functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ implementations:
constexpr RetT ctz(T data) {
return std::countr_zero<std::make_unsigned_t<T>>(data);
}

template<typename T, typename RetT>
constexpr RetT popcount(T data) {
return std::popcount<std::make_unsigned_t<T>>(data);
}
}
#else
namespace details {
Expand Down Expand Up @@ -73,6 +78,17 @@ implementations:
}
}
}
template <typename T, typename RetT>
RetT popcount(T data) {
static_assert(sizeof(T) <= sizeof(unsigned long long), "Unsupported type");
if constexpr(sizeof(T) <= sizeof(unsigned int)) {
return __builtin_popcount(data);
} else if constexpr(sizeof(T) <= sizeof(unsigned long)) {
return __builtin_popcountl(data);
} else if constexpr(sizeof(T) <= sizeof(unsigned long long)) {
return __builtin_popcountll(data);
}
}
}
#endif
- |
Expand Down
120 changes: 79 additions & 41 deletions generator/static_files/core/utils/preprocessor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,90 @@ implementations:
# define TSL_UNROLL(...)
#endif
- |
template <typename T, class = void> struct class_declared : std::false_type {};
template <typename T> struct class_declared<T,decltype(void(sizeof(T)))> : std::true_type {};
- |
template <class HelperStruct>
struct tsl_functor_template_defined {
// Define a helper function that checks if apply can be instantiated with specific arguments.
template <typename... Args>
static auto has_valid_apply(Args&&...) -> decltype(std::declval<HelperStruct>().apply(std::declval<Args>()...), std::true_type{});
// If the helper function is well-formed, it means apply can be instantiated with these arguments.
template <typename... Args>
static std::true_type test(int, Args&&...);
// If the helper function is not well-formed, it means apply cannot be instantiated with these arguments.
template <typename T, class = void>
struct tsl_functor_declared : std::false_type {};
template <typename T>
struct tsl_functor_declared<T,decltype(void(sizeof(T)))> : std::true_type {};
template <typename T>
struct has_param_tuple_t {
template <typename C>
static std::true_type test(typename C::param_tuple_t*);
template <typename>
static std::false_type test(...);
// Combine the results of the tests.
template <typename... Args>
using type = decltype(test(0, std::declval<Args>()...));
static constexpr bool value = type<>::value;
static constexpr bool value = decltype(test<T>(nullptr))::value;
};
- |
template <class HelperStruct>
struct tsl_functor_plain_defined {
template <class CurrentHelperStruct>
static auto test(int) -> decltype(std::declval<CurrentHelperStruct>().apply, std::true_type{});
template <typename T>
struct has_parameter_pack_type_t {
template <typename C>
static std::true_type test(typename C::gets_parameter_pack*);
template <typename>
static std::false_type test(...);
static constexpr bool value = decltype(test<T>(nullptr))::value;
};
template <typename T, class = void>
struct gets_parameter_pack_t : public std::false_type {};
template <typename T>
struct gets_parameter_pack_t<T, std::enable_if_t<(has_parameter_pack_type_t<T>::value)>> : public T::gets_parameter_pack {};
template <typename T>
struct has_apply {
template <typename C>
static std::true_type test(decltype(&C::apply));
template <typename>
static auto test(...) -> std::false_type;
using type = decltype(test<HelperStruct>(0));
static constexpr bool value = type::value;
static std::false_type test(...);
static constexpr bool value = decltype(test<T>(nullptr))::value;
};
- |
template <class HelperStruct>
template <typename T>
struct has_pack_apply {
template <typename C, typename... Args>
static auto test(int) -> decltype(C::template apply<Args...>, std::true_type{});
template <typename>
static std::false_type test(...);
static constexpr bool value = decltype(test<T>(0))::value;
};
template <typename T>
struct tsl_functor_defined {
static constexpr bool value =
tsl_functor_template_defined<HelperStruct>::value ||
tsl_functor_plain_defined<HelperStruct>::value;
static constexpr bool value = ((has_param_tuple_t<T>::value) || (gets_parameter_pack_t<T>::value)) && ((has_apply<T>::value) || (has_pack_apply<T>::value));
};
- |
template<class A, class B>
constexpr bool tsl_primitive_ambiguous() {
if constexpr ((class_declared<A>::value)) {
if constexpr ((tsl_functor_defined<A>::value) && (tsl_functor_defined<B>::value)) {
return std::is_same_v<typename A::param_tuple_t, typename B::param_tuple_t>;
} else {
return false;
}
} else {
return false;
}
}
template <typename T, class = void>
struct tsl_functor_available : std::false_type {};
template <typename T>
struct tsl_functor_available<
T,
std::enable_if_t<((tsl_functor_declared<T>::value) && (tsl_functor_defined<T>::value))>
> : std::true_type {};
template <typename A, typename B, class = void>
struct tsl_functor_pair_available : std::false_type {};
template <typename A, typename B>
struct tsl_functor_pair_available<
A, B,
std::enable_if_t<((tsl_functor_available<A>::value) && (tsl_functor_available<B>::value))>
> : public std::true_type {};
- |
template <typename First, typename Second, class = void>
struct tsl_primitive_redeclaration {
static constexpr bool value = false;
};
template <typename First, typename Second>
struct tsl_primitive_redeclaration<
First, Second,
std::enable_if_t<tsl_functor_pair_available<First, Second>::value>
> {
static constexpr bool value = std::is_same_v<typename First::param_tuple_t, typename Second::param_tuple_t>;
};
template <class... Functors>
struct tsl_primitives_redeclared;
template <class Functor>
struct tsl_primitives_redeclared<Functor> {
using is_ambiguous = std::false_type;
};
template <class FunctorA, class FunctorB, class... Functors>
struct tsl_primitives_redeclared<FunctorA, FunctorB, Functors...> {
using is_ambiguous = std::conditional_t<tsl_primitive_redeclaration<FunctorA, FunctorB>::value,
std::true_type,
typename tsl_primitives_redeclared<FunctorA, Functors...>::is_ambiguous>;
};
template <class... Functors>
inline constexpr bool tsl_primitives_redeclared_v = tsl_primitives_redeclared<Functors...>::is_ambiguous::value;

...
40 changes: 40 additions & 0 deletions generator/static_files/core/utils/type_helper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,46 @@ implementations:
}
return r;
}
template <>
std::string type_name<uint8_t>() {
return "uint8_t";
}
template <>
std::string type_name<uint16_t>() {
return "uint16_t";
}
template <>
std::string type_name<uint32_t>() {
return "uint32_t";
}
template <>
std::string type_name<uint64_t>() {
return "uint64_t";
}
template <>
std::string type_name<int8_t>() {
return "int8_t";
}
template <>
std::string type_name<int16_t>() {
return "int16_t";
}
template <>
std::string type_name<int32_t>() {
return "int32_t";
}
template <>
std::string type_name<int64_t>() {
return "int64_t";
}
template <>
std::string type_name<float>() {
return "float";
}
template <>
std::string type_name<double>() {
return "double";
}
#define TYPENAME(x) type_name<decltype(x)>()

- |
Expand Down
1 change: 1 addition & 0 deletions primitive_data/extensions/simd/intel/avx512.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ arch_flags:
"avx512_fp16": "avx512fp16"
"avx512_vpopcntdq": "avx512vpopcntdq"
"avx512_vbmi2": "avx512vbmi2"
"avx512_bitalg": "avx512bitalg"

includes: ['"immintrin.h"']
simdT_name: "avx512"
Expand Down
Loading
Loading