forked from open-quantum-safe/liboqs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhauled compiler-time CPU-extension detection. (open-quantum-safe#713
) Refactored .CMake/alg_support.cmake, and kem/ and sig/ CMakeLists.txt files. Refactored copy_from_pqclean/ templating. Added custom x64 CPU extension detection code and removed cpu_features. Removed duplicate Kyber source directories.
- Loading branch information
Showing
295 changed files
with
1,105 additions
and
7,643 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdio.h> | ||
|
||
int main(void) { | ||
#if defined(__AES__) | ||
printf("AES;"); | ||
#endif | ||
#if defined(__AVX__) | ||
printf("AVX;"); | ||
#endif | ||
#if defined(__AVX2__) | ||
printf("AVX2;"); | ||
#endif | ||
#if defined(__AVX512BW__) | ||
printf("AVX512BW;"); | ||
#endif | ||
#if defined(__AVX512DQ__) | ||
printf("AVX512DQ;"); | ||
#endif | ||
#if defined(__AVX512F__) | ||
printf("AVX512F;"); | ||
#endif | ||
#if defined(__BMI__) | ||
printf("BMI;"); | ||
#endif | ||
#if defined(__BMI2__) | ||
printf("BMI2;"); | ||
#endif | ||
#if defined(__FMA__) | ||
printf("FMA;"); | ||
#endif | ||
#if defined(__POPCNT__) | ||
printf("POPCNT;"); | ||
#endif | ||
#if defined(__SSE__) | ||
printf("SSE;"); | ||
#endif | ||
#if defined(__SSE2__) | ||
printf("SSE2;"); | ||
#endif | ||
#if defined(__SSE3__) | ||
printf("SSE3;"); | ||
#endif | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
try_run(RUN_RESULT COMPILE_RESULT | ||
"${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/.CMake/detect_gcc_clang_intrinsics.c" | ||
COMPILE_DEFINITIONS -march=native | ||
RUN_OUTPUT_VARIABLE RUN_OUTPUT) | ||
if(NOT RUN_RESULT EQUAL 0) | ||
message(FATAL_ERROR ".CMake/detect_gcc_clang_intrinsics.c returned exit code: " ${RUN_RESULT}) | ||
endif() | ||
foreach(CPU_EXTENSION ${RUN_OUTPUT}) | ||
set(OQS_USE_${CPU_EXTENSION}_INSTRUCTIONS ON) | ||
endforeach() | ||
if(OQS_USE_AVX512BW_INSTRUCTIONS AND | ||
OQS_USE_AVX512DQ_INSTRUCTIONS AND | ||
OQS_USE_AVX512F_INSTRUCTIONS) | ||
set(OQS_USE_AVX512_INSTRUCTIONS ON) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 18 additions & 33 deletions
51
scripts/copy_from_pqclean/.CMake/alg_support.cmake/add_enable_by_alg.fragment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,28 @@ | ||
|
||
{% for family in instructions['kems'] %} | ||
option(OQS_ENABLE_KEM_{{ family['name']|upper }} "" ON) | ||
{%- for scheme in family['schemes'] %} | ||
{%- for scheme in family['schemes'] %} | ||
cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }} "" ON "OQS_ENABLE_KEM_{{ family['name']|upper }}" OFF) | ||
{% for impl in scheme['metadata']['implementations'] -%} | ||
{% if impl['supported_platforms'] -%} | ||
{% for platform in impl['supported_platforms'] -%} | ||
{% for os in platform['operating_systems'] -%} | ||
if ({{ os }} STREQUAL CMAKE_SYSTEM_NAME) | ||
if ({{ impl['cmake_options'] }}) | ||
set(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} ON) | ||
endif() | ||
{%- for impl in scheme['metadata']['implementations'] if impl['name'] != family['default_implementation'] and impl['supported_platforms'] -%} | ||
{%- for platform in impl['supported_platforms'] if platform['architecture'] == 'x86_64' %} | ||
if(ARCH STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME MATCHES "{{ platform['operating_systems']|join('|') }}" {%- if platform['required_flags'] %} AND {% for flag in platform['required_flags'] -%} OQS_USE_{{ flag|upper }}_INSTRUCTIONS {%- if not loop.last %} AND {% endif -%}{%- endfor -%}{%- endif -%}) | ||
cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}" OFF) | ||
endif() | ||
{%- endfor -%} | ||
{%- endfor -%} | ||
{%- endfor %} | ||
{% endfor -%} | ||
{% endfor -%} | ||
{% else -%} | ||
set(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} ON) | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endfor %} | ||
{% endfor -%} | ||
|
||
{% for family in instructions['sigs'] %} | ||
option(OQS_ENABLE_SIG_{{ family['name']|upper }} "" ON) | ||
{%- for scheme in family['schemes'] %} | ||
{%- for scheme in family['schemes'] %} | ||
cmake_dependent_option(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }} "" ON "OQS_ENABLE_SIG_{{ family['name']|upper }}" OFF) | ||
{% for impl in scheme['metadata']['implementations'] -%} | ||
{% if impl['supported_platforms'] -%} | ||
{% for platform in impl['supported_platforms'] -%} | ||
{% for os in platform['operating_systems'] -%} | ||
if ({{ os }} STREQUAL CMAKE_SYSTEM_NAME) | ||
if ({{ impl['cmake_options'] }}) | ||
set(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} ON) | ||
endif() | ||
{%- for impl in scheme['metadata']['implementations'] if impl['name'] != family['default_implementation'] and impl['supported_platforms'] -%} | ||
{%- for platform in impl['supported_platforms'] if platform['architecture'] == 'x86_64' %} | ||
if(ARCH STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME MATCHES "{{ platform['operating_systems']|join('|') }}" {%- if platform['required_flags'] %} AND {% for flag in platform['required_flags'] -%} OQS_USE_{{ flag|upper }}_INSTRUCTIONS {%- if not loop.last %} AND {% endif -%}{%- endfor -%}{%- endif -%}) | ||
cmake_dependent_option(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}" OFF) | ||
endif() | ||
{%- endfor -%} | ||
{%- endfor -%} | ||
{%- endfor %} | ||
{% endfor -%} | ||
{% endfor -%} | ||
{% else -%} | ||
set(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} ON) | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endfor %} | ||
{% endfor %} | ||
|
Oops, something went wrong.