Skip to content

Commit

Permalink
fix #1588 (#1590)
Browse files Browse the repository at this point in the history
* fix #1588

* Fix spelling and allow glaze grouping in Cmake

* Delete avx.cmake

* glaze_DISABLE_AVX2_WHEN_SUPPORTED -> glaze_DISABLE_SIMD_WHEN_SUPPORTED

---------

Co-authored-by: Artur Bać <artur@ebasoft.com.pl>
Co-authored-by: Stephen Berry <stephenberry.developer@gmail.com>
  • Loading branch information
3 people authored Feb 4, 2025
1 parent 48d8ed5 commit b92ddaf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 71 deletions.
13 changes: 4 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ if (glaze_DEVELOPER_MODE)
include(cmake/dev-mode.cmake)
endif()

if (APPLE)
option(glaze_ENABLE_AVX2 "Enable AVX2 instruction set" OFF)
else()
option(glaze_ENABLE_AVX2 "Enable AVX2 instruction set" ON)
message("Glaze is being compiled with AVX2 instructions. Set glaze_ENABLE_AVX2 to OFF if you wish to disable this.")
endif()

if (glaze_ENABLE_AVX2)
include(cmake/avx.cmake)
option(glaze_DISABLE_SIMD_WHEN_SUPPORTED
"disable SIMD optimizations even when targets support it (e.g. AVX2)" OFF)
if(glaze_DISABLE_SIMD_WHEN_SUPPORTED)
target_compile_definitions(glaze_glaze INTERFACE GLZ_DISABLE_SIMD)
endif()

option(glaze_BUILD_EXAMPLES "Build GLAZE examples" OFF)
Expand Down
57 changes: 0 additions & 57 deletions cmake/avx.cmake

This file was deleted.

16 changes: 11 additions & 5 deletions include/glaze/json/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
#include <ostream>
#include <variant>

#if defined(__APPLE__)
#elif defined(_MSC_VER)
#include <intrin.h>
#elif defined(GLZ_USE_AVX2)
#include <immintrin.h>
#if !defined(GLZ_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64))
#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <immintrin.h>
#endif

#if defined(__AVX2__)
#define GLZ_USE_AVX2
#endif
#endif


#include "glaze/core/opts.hpp"
#include "glaze/core/reflect.hpp"
#include "glaze/core/write.hpp"
Expand Down

0 comments on commit b92ddaf

Please sign in to comment.