From 7d6299eeb902ff7a509691cd893d727169ce2c39 Mon Sep 17 00:00:00 2001 From: Matthew Andres Moreno Date: Fri, 14 Oct 2022 01:54:45 -0700 Subject: [PATCH] Fixup codegen, add sgp-lite content --- .../_codegen/pylib/_get_header_content.py | 20 ++++--- .../_codegen/pylib/_iter_header_paths.py | 11 +++- include/uit_emp/base/macros.hpp | 20 +++++++ include/uit_emp/datastructs/Cache.hpp | 20 +++++++ include/uit_emp/matching/MatchDepository.hpp | 20 +++++++ include/uit_emp/matching/matchbin_metrics.hpp | 20 +++++++ .../regulators/PlusCountdownRegulator.hpp | 20 +++++++ .../selectors_static/RankedSelector.hpp | 20 +++++++ include/uit_emp/math/Distribution.hpp | 20 +++++++ include/uit_emp/tools/hash_namify.hpp | 20 +++++++ .../uit_emp/vendorization/pop_headerguards.hh | 50 ++-------------- .../vendorization/push_headerguards.hh | 60 ++----------------- 12 files changed, 193 insertions(+), 108 deletions(-) create mode 100644 include/uit_emp/base/macros.hpp create mode 100644 include/uit_emp/datastructs/Cache.hpp create mode 100644 include/uit_emp/matching/MatchDepository.hpp create mode 100644 include/uit_emp/matching/matchbin_metrics.hpp create mode 100644 include/uit_emp/matching/regulators/PlusCountdownRegulator.hpp create mode 100644 include/uit_emp/matching/selectors_static/RankedSelector.hpp create mode 100644 include/uit_emp/math/Distribution.hpp create mode 100644 include/uit_emp/tools/hash_namify.hpp diff --git a/include/uit_emp/_codegen/pylib/_get_header_content.py b/include/uit_emp/_codegen/pylib/_get_header_content.py index 4743937a9..268f496a9 100644 --- a/include/uit_emp/_codegen/pylib/_get_header_content.py +++ b/include/uit_emp/_codegen/pylib/_get_header_content.py @@ -8,14 +8,16 @@ def get_header_content() -> typing.List[str]: for header_path in iter_header_paths(): - echo = subprocess.Popen( + print(header_path) + echo = subprocess.run( ( "printf", f'#include "../../third-party/Empirical/include/emp/{header_path}" \n int main(){{}}', ), - stdout=subprocess.PIPE, + check=True, + capture_output=True, ) - header_content = subprocess.check_output( + header_content = subprocess.run( [ "g++", "-std=c++17", @@ -26,14 +28,16 @@ def get_header_content() -> typing.List[str]: "-o", "/dev/null", ], - stdin=echo.stdout, - stderr=subprocess.STDOUT, - ) + input=echo.stdout, + check=True, + capture_output=True, + ).stderr.decode() res = [] - for line in header_content.decode().splitlines(): + for line in header_content.splitlines(): + if "Empirical" in line: if ' ' in line: line = line.split()[1] with open(line) as file: res.append(file.read()) - return res + return res diff --git a/include/uit_emp/_codegen/pylib/_iter_header_paths.py b/include/uit_emp/_codegen/pylib/_iter_header_paths.py index 1b2d1efc2..d1d92365e 100644 --- a/include/uit_emp/_codegen/pylib/_iter_header_paths.py +++ b/include/uit_emp/_codegen/pylib/_iter_header_paths.py @@ -7,19 +7,28 @@ def iter_header_paths() -> typing.Iterator[str]: # ) yield from ( + "base/macros.hpp", + "config/config.hpp", "data/DataNode.hpp", "data/DataFile.hpp", - "datastructs/QueueCache.hpp", + "datastructs/Cache.hpp", "datastructs/hash_utils.hpp", "datastructs/tuple_utils.hpp", + "datastructs/QueueCache.hpp", "io/ContiguousStream.hpp", "io/MemoryIStream.hpp", + "matching/matchbin_metrics.hpp", + "matching/MatchDepository.hpp", + "matching/regulators/PlusCountdownRegulator.hpp", + "matching/selectors_static/RankedSelector.hpp", + "math/Distribution.hpp", "math/math.hpp", "math/Random.hpp", "math/random_utils.hpp", "meta/meta.hpp", "meta/TypePack.hpp", "polyfill/span.hpp", + "tools/hash_namify.hpp", "tools/string_utils.hpp", "tools/keyname_utils.hpp", ) diff --git a/include/uit_emp/base/macros.hpp b/include/uit_emp/base/macros.hpp new file mode 100644 index 000000000..46e97a40d --- /dev/null +++ b/include/uit_emp/base/macros.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_BASE_MACROS_HPP_INCLUDE +#define UIT_EMP_BASE_MACROS_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/base/macros.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_BASE_MACROS_HPP_INCLUDE diff --git a/include/uit_emp/datastructs/Cache.hpp b/include/uit_emp/datastructs/Cache.hpp new file mode 100644 index 000000000..ed2b22250 --- /dev/null +++ b/include/uit_emp/datastructs/Cache.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_DATASTRUCTS_CACHE_HPP_INCLUDE +#define UIT_EMP_DATASTRUCTS_CACHE_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/datastructs/Cache.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_DATASTRUCTS_CACHE_HPP_INCLUDE diff --git a/include/uit_emp/matching/MatchDepository.hpp b/include/uit_emp/matching/MatchDepository.hpp new file mode 100644 index 000000000..6878554aa --- /dev/null +++ b/include/uit_emp/matching/MatchDepository.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_MATCHING_MATCHDEPOSITORY_HPP_INCLUDE +#define UIT_EMP_MATCHING_MATCHDEPOSITORY_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/matching/MatchDepository.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_MATCHING_MATCHDEPOSITORY_HPP_INCLUDE diff --git a/include/uit_emp/matching/matchbin_metrics.hpp b/include/uit_emp/matching/matchbin_metrics.hpp new file mode 100644 index 000000000..6cf07aec8 --- /dev/null +++ b/include/uit_emp/matching/matchbin_metrics.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_MATCHING_MATCHBIN_METRICS_HPP_INCLUDE +#define UIT_EMP_MATCHING_MATCHBIN_METRICS_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/matching/matchbin_metrics.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_MATCHING_MATCHBIN_METRICS_HPP_INCLUDE diff --git a/include/uit_emp/matching/regulators/PlusCountdownRegulator.hpp b/include/uit_emp/matching/regulators/PlusCountdownRegulator.hpp new file mode 100644 index 000000000..6272c1c5f --- /dev/null +++ b/include/uit_emp/matching/regulators/PlusCountdownRegulator.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_MATCHING_REGULATORS_PLUSCOUNTDOWNREGULATOR_HPP_INCLUDE +#define UIT_EMP_MATCHING_REGULATORS_PLUSCOUNTDOWNREGULATOR_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../../third-party/Empirical/include/emp/matching/regulators/PlusCountdownRegulator.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_MATCHING_REGULATORS_PLUSCOUNTDOWNREGULATOR_HPP_INCLUDE diff --git a/include/uit_emp/matching/selectors_static/RankedSelector.hpp b/include/uit_emp/matching/selectors_static/RankedSelector.hpp new file mode 100644 index 000000000..2673f85a0 --- /dev/null +++ b/include/uit_emp/matching/selectors_static/RankedSelector.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_MATCHING_SELECTORS_STATIC_RANKEDSELECTOR_HPP_INCLUDE +#define UIT_EMP_MATCHING_SELECTORS_STATIC_RANKEDSELECTOR_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../../third-party/Empirical/include/emp/matching/selectors_static/RankedSelector.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_MATCHING_SELECTORS_STATIC_RANKEDSELECTOR_HPP_INCLUDE diff --git a/include/uit_emp/math/Distribution.hpp b/include/uit_emp/math/Distribution.hpp new file mode 100644 index 000000000..d45f4a934 --- /dev/null +++ b/include/uit_emp/math/Distribution.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_MATH_DISTRIBUTION_HPP_INCLUDE +#define UIT_EMP_MATH_DISTRIBUTION_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/math/Distribution.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_MATH_DISTRIBUTION_HPP_INCLUDE diff --git a/include/uit_emp/tools/hash_namify.hpp b/include/uit_emp/tools/hash_namify.hpp new file mode 100644 index 000000000..edc55cf8b --- /dev/null +++ b/include/uit_emp/tools/hash_namify.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef UIT_EMP_TOOLS_HASH_NAMIFY_HPP_INCLUDE +#define UIT_EMP_TOOLS_HASH_NAMIFY_HPP_INCLUDE + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/push_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#include "../../../third-party/Empirical/include/emp/tools/hash_namify.hpp" + +#ifndef UIT_VENDORIZE_EMP +namespace emp {} +namespace uit_emp = emp; +#endif // #ifndef UIT_VENDORIZE_EMP + +#ifdef UIT_VENDORIZE_EMP +#include "../vendorization/pop_uit_emp.hh" +#endif // #ifdef UIT_VENDORIZE_EMP + +#endif // #ifndef UIT_EMP_TOOLS_HASH_NAMIFY_HPP_INCLUDE diff --git a/include/uit_emp/vendorization/pop_headerguards.hh b/include/uit_emp/vendorization/pop_headerguards.hh index fb80b46a7..35ae1ac7f 100644 --- a/include/uit_emp/vendorization/pop_headerguards.hh +++ b/include/uit_emp/vendorization/pop_headerguards.hh @@ -25,36 +25,16 @@ #endif // #ifdef EMP_BASE_EMP_NAMESPACE_HPP #pragma pop_macro("EMP_BASE_EMP_NAMESPACE_HPP") -#ifdef EMP_BITSET_UTILS_H -#define UIT_EMP_BITSET_UTILS_H_HEADERGUARD -#endif // #ifdef EMP_BITSET_UTILS_H -#pragma pop_macro("EMP_BITSET_UTILS_H") - -#ifdef EMP_CONST_H -#define UIT_EMP_CONST_H_HEADERGUARD -#endif // #ifdef EMP_CONST_H -#pragma pop_macro("EMP_CONST_H") - -#ifdef EMP_DATA_NODE_H -#define UIT_EMP_DATA_NODE_H_HEADERGUARD -#endif // #ifdef EMP_DATA_NODE_H -#pragma pop_macro("EMP_DATA_NODE_H") - -#ifdef EMP_FUNCTION_SET_H -#define UIT_EMP_FUNCTION_SET_H_HEADERGUARD -#endif // #ifdef EMP_FUNCTION_SET_H -#pragma pop_macro("EMP_FUNCTION_SET_H") - -#ifdef EMP_INDEX_MAP_H -#define UIT_EMP_INDEX_MAP_H_HEADERGUARD -#endif // #ifdef EMP_INDEX_MAP_H -#pragma pop_macro("EMP_INDEX_MAP_H") - #ifdef EMP_IS_STREAMABLE_HPP #define UIT_EMP_IS_STREAMABLE_HPP_HEADERGUARD #endif // #ifdef EMP_IS_STREAMABLE_HPP #pragma pop_macro("EMP_IS_STREAMABLE_HPP") +#ifdef EMP_KEY_NAME_UTILS_H +#define UIT_EMP_KEY_NAME_UTILS_H_HEADERGUARD +#endif // #ifdef EMP_KEY_NAME_UTILS_H +#pragma pop_macro("EMP_KEY_NAME_UTILS_H") + #ifdef EMP_MACROS_H #define UIT_EMP_MACROS_H_HEADERGUARD #endif // #ifdef EMP_MACROS_H @@ -65,11 +45,6 @@ #endif // #ifdef EMP_MACRO_MATH_H #pragma pop_macro("EMP_MACRO_MATH_H") -#ifdef EMP_MATH_H -#define UIT_EMP_MATH_H_HEADERGUARD -#endif // #ifdef EMP_MATH_H -#pragma pop_macro("EMP_MATH_H") - #ifdef EMP_META_H #define UIT_EMP_META_H_HEADERGUARD #endif // #ifdef EMP_META_H @@ -90,16 +65,6 @@ #endif // #ifdef EMP_PTR_H #pragma pop_macro("EMP_PTR_H") -#ifdef EMP_RANDOM_H -#define UIT_EMP_RANDOM_H_HEADERGUARD -#endif // #ifdef EMP_RANDOM_H -#pragma pop_macro("EMP_RANDOM_H") - -#ifdef EMP_RANGE_H -#define UIT_EMP_RANGE_H_HEADERGUARD -#endif // #ifdef EMP_RANGE_H -#pragma pop_macro("EMP_RANGE_H") - #ifdef EMP_REFLECTION_H #define UIT_EMP_REFLECTION_H_HEADERGUARD #endif // #ifdef EMP_REFLECTION_H @@ -130,11 +95,6 @@ #endif // #ifdef EMP_TYPE_TRAITS_H #pragma pop_macro("EMP_TYPE_TRAITS_H") -#ifdef EMP_VAL_PACK_H -#define UIT_EMP_VAL_PACK_H_HEADERGUARD -#endif // #ifdef EMP_VAL_PACK_H -#pragma pop_macro("EMP_VAL_PACK_H") - #ifdef EMP_VECTOR_H #define UIT_EMP_VECTOR_H_HEADERGUARD #endif // #ifdef EMP_VECTOR_H diff --git a/include/uit_emp/vendorization/push_headerguards.hh b/include/uit_emp/vendorization/push_headerguards.hh index 120d1a6dd..f53062382 100644 --- a/include/uit_emp/vendorization/push_headerguards.hh +++ b/include/uit_emp/vendorization/push_headerguards.hh @@ -30,42 +30,18 @@ #define EMP_BASE_EMP_NAMESPACE_HPP #endif -#pragma push_macro("EMP_BITSET_UTILS_H") -#undef EMP_BITSET_UTILS_H -#ifdef UIT_EMP_BITSET_UTILS_H_HEADERGUARD -#define EMP_BITSET_UTILS_H -#endif - -#pragma push_macro("EMP_CONST_H") -#undef EMP_CONST_H -#ifdef UIT_EMP_CONST_H_HEADERGUARD -#define EMP_CONST_H -#endif - -#pragma push_macro("EMP_DATA_NODE_H") -#undef EMP_DATA_NODE_H -#ifdef UIT_EMP_DATA_NODE_H_HEADERGUARD -#define EMP_DATA_NODE_H -#endif - -#pragma push_macro("EMP_FUNCTION_SET_H") -#undef EMP_FUNCTION_SET_H -#ifdef UIT_EMP_FUNCTION_SET_H_HEADERGUARD -#define EMP_FUNCTION_SET_H -#endif - -#pragma push_macro("EMP_INDEX_MAP_H") -#undef EMP_INDEX_MAP_H -#ifdef UIT_EMP_INDEX_MAP_H_HEADERGUARD -#define EMP_INDEX_MAP_H -#endif - #pragma push_macro("EMP_IS_STREAMABLE_HPP") #undef EMP_IS_STREAMABLE_HPP #ifdef UIT_EMP_IS_STREAMABLE_HPP_HEADERGUARD #define EMP_IS_STREAMABLE_HPP #endif +#pragma push_macro("EMP_KEY_NAME_UTILS_H") +#undef EMP_KEY_NAME_UTILS_H +#ifdef UIT_EMP_KEY_NAME_UTILS_H_HEADERGUARD +#define EMP_KEY_NAME_UTILS_H +#endif + #pragma push_macro("EMP_MACROS_H") #undef EMP_MACROS_H #ifdef UIT_EMP_MACROS_H_HEADERGUARD @@ -78,12 +54,6 @@ #define EMP_MACRO_MATH_H #endif -#pragma push_macro("EMP_MATH_H") -#undef EMP_MATH_H -#ifdef UIT_EMP_MATH_H_HEADERGUARD -#define EMP_MATH_H -#endif - #pragma push_macro("EMP_META_H") #undef EMP_META_H #ifdef UIT_EMP_META_H_HEADERGUARD @@ -108,18 +78,6 @@ #define EMP_PTR_H #endif -#pragma push_macro("EMP_RANDOM_H") -#undef EMP_RANDOM_H -#ifdef UIT_EMP_RANDOM_H_HEADERGUARD -#define EMP_RANDOM_H -#endif - -#pragma push_macro("EMP_RANGE_H") -#undef EMP_RANGE_H -#ifdef UIT_EMP_RANGE_H_HEADERGUARD -#define EMP_RANGE_H -#endif - #pragma push_macro("EMP_REFLECTION_H") #undef EMP_REFLECTION_H #ifdef UIT_EMP_REFLECTION_H_HEADERGUARD @@ -156,12 +114,6 @@ #define EMP_TYPE_TRAITS_H #endif -#pragma push_macro("EMP_VAL_PACK_H") -#undef EMP_VAL_PACK_H -#ifdef UIT_EMP_VAL_PACK_H_HEADERGUARD -#define EMP_VAL_PACK_H -#endif - #pragma push_macro("EMP_VECTOR_H") #undef EMP_VECTOR_H #ifdef UIT_EMP_VECTOR_H_HEADERGUARD