Skip to content

Commit 7fdf322

Browse files
committed
Jsonifier Release v0.9.9 - Pre-merge
-Modified some concepts. -Modified the DetectArchitecture.cmake script. -Also adding a couple of concepts. -Implemented a bunch of compile-time loops instead of runtime ones. -Implemented a new find function for the string classes. -Also added a couple of concepts. -Removed a bunch of superfluous constructors/destructors/copy/move operators. -Updated some of the integer-postfixes. -Switched to camel-case for types, and concepts. -Modified the DetectArchitecture.cmake script. -Added the check for the lzcnt instruction. -Added a universal fallback tzcnt function. -Modified the string class. -Removed a few unnecessary explicit template parameters. -Implemented the new SelectMenuDefaultValues type. -Improved the ISADetection headers, by splitting it into multiple different headers. -Added an implementation for parsing tuple-array-types. -Moved the concepts out into their own header.
1 parent 5d53427 commit 7fdf322

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4691
-4862
lines changed

.github/workflows/CLANG_18-Ubuntu.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ jobs:
2828
sudo ./llvm.sh 18
2929
3030
- name: Configure CMake
31-
working-directory: Tests
31+
working-directory: ./
3232
run: |
33-
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/bin/clang++-18 -DGITHUB_BRANCH_TYPE=${{github.ref}}
33+
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/bin/clang++-18 -DDEV=true -DJSONIFIER_TEST=true
3434
3535
- name: Build the Test
36-
working-directory: Tests/Build
36+
working-directory: ./Build
3737
run: |
3838
cmake --build . --config=${{matrix.build_type}}
3939
4040
- name: Run the Test
41-
working-directory: Tests/Build
41+
working-directory: ./Build/Tests
4242
run: |
4343
./Json-Performance
4444
continue-on-error: true

.github/workflows/GCC_13-MacOS.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ jobs:
2525
brew install gcc
2626
2727
- name: Configure CMake
28-
working-directory: Tests
28+
working-directory: ./
2929
run: |
3030
31-
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/local/opt/gcc@13/bin/g++-13 -DGITHUB_BRANCH_TYPE=${{github.ref}}
31+
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/local/opt/gcc@13/bin/g++-13 -DDEV=true -DJSONIFIER_TEST=true
3232
3333
- name: Build the Test
34-
working-directory: Tests/Build
34+
working-directory: ./Build
3535
run: |
3636
cmake --build . --config=${{matrix.build_type}}
3737
3838
- name: Run the Test
39-
working-directory: Tests/Build
39+
working-directory: ./Build/Tests
4040
run: |
4141
./Json-Performance
4242
continue-on-error: true

.github/workflows/MSVC_2022-Windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ jobs:
2727
value: $env:PATH;C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build
2828

2929
- name: Configure CMake
30-
working-directory: Tests
30+
working-directory: ./
3131
run: |
32-
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DGITHUB_BRANCH_TYPE=${{github.ref}}
32+
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DDEV=true -DJSONIFIER_TEST=true
3333
3434
- name: Build the Test
35-
working-directory: Tests/Build
35+
working-directory: ./Build
3636
run: |
3737
cmake --build . --config=${{matrix.build_type}}
3838
3939
- name: Run the Test
40-
working-directory: Tests/Build/${{matrix.build_type}}/
40+
working-directory: ./Build/Tests/${{matrix.build_type}}
4141
run: |
4242
./Json-Performance.exe
4343
continue-on-error: true

BuildTools/Classes/Packager/Vcpkg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
159159
"description": "A few classes for parsing and serializing json - very rapidly.",
160160
"homepage": "https://github.com/realtimechris/jsonifier",
161161
"license": "MIT",
162-
"supports": "(windows & x64 & !uwp & !xbox) | (linux & x64) | (osx & x64)",
162+
"supports": "(windows & x64 & !xbox) | (linux & x64) | (osx & x64)",
163163
"dependencies": [
164164
{
165165
"name": "vcpkg-cmake",

CMake/CollectVersion.cmake

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3+
#
4+
# Copyright 2021, 2022, 2023 Chris M. (RealTimeChris)
5+
#
6+
# This library is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU Lesser General Public
8+
# License as published by the Free Software Foundation; either
9+
# version 2.1 of the License, or (at your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with this library; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19+
# USA
20+
#
21+
# CollectVersion.cmake - The script for collecting the library's version..
22+
# May 13, 2021
23+
# https://discordcoreapi.com
24+
25+
function(collect_version project_name)
26+
27+
set(PRODUCT_VERSION "")
28+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/Vcpkg/ports/${project_name}/vcpkg.json" JSON_STRING)
29+
foreach(IDX RANGE 1)
30+
string(JSON PRODUCT_VERSION GET "${JSON_STRING}" "version")
31+
endforeach()
32+
string(REPLACE "." ";" PRODUCT_VERSION_LIST "${PRODUCT_VERSION}")
33+
list(GET PRODUCT_VERSION_LIST 0 VERSION_MAJOR)
34+
list(APPEND PRODUCT_VERSION_NEW "${VERSION_MAJOR}")
35+
set(VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE)
36+
list(GET PRODUCT_VERSION_LIST 1 VERSION_MINOR)
37+
list(APPEND PRODUCT_VERSION_NEW "${VERSION_MINOR}")
38+
set(VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE)
39+
list(LENGTH PRODUCT_VERSION_LIST LIST_SIZE)
40+
if (LIST_SIZE GREATER 2)
41+
list(GET PRODUCT_VERSION_LIST 2 VERSION_PATCH)
42+
set(VERSION_PATCH "${VERSION_PATCH}" PARENT_SCOPE)
43+
list(APPEND PRODUCT_VERSION_NEW "${VERSION_PATCH}")
44+
endif()
45+
string(REPLACE ";" "." PRODUCT_VERSION_NEW "${PRODUCT_VERSION_NEW}")
46+
set(PRODUCT_VERSION "${PRODUCT_VERSION_NEW}" PARENT_SCOPE)
47+
48+
endfunction()

CMake/DetectArchitecture.cmake

Lines changed: 0 additions & 69 deletions
This file was deleted.

CMake/JsonifierConfig.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@PACKAGE_INIT@
22

3-
set_and_check(EXPORT_TARGETS_FILE_NEW "@PACKAGE_EXPORTED_TARGETS_FILE_PATH@")
3+
set_and_check(EXPORT_TARGETS_FILE_NEW "@PACKAGE_EXPORTED_TARGETS_FILE_PATH@")
44

55
include("${EXPORT_TARGETS_FILE_NEW}")
66

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2023 RealTimeChris
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
# software and associated documentation files (the "Software"), to deal in the Software
7+
# without restriction, including without limitation the rights to use, copy, modify, merge,
8+
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit
9+
# persons to whom the Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all copies or
12+
# substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
# DEALINGS IN THE SOFTWARE.
20+
# JsonifierDetectArchitecture.cmake - Script for detecting the CPU architecture.
21+
# Sept 18, 2023
22+
# https://discordcoreapi.com
23+
include(CheckCXXSourceRuns)
24+
25+
function(jsonifier_check_instruction_set INSTRUCTION_SET_NAME INSTRUCTION_SET_IN_FLAG INSTRUCTION_SET_OUT_FLAG INSTRUCTION_SET_INTRINSIC)
26+
set(INSTRUCTION_SET_CODE "
27+
#include <immintrin.h>
28+
#include <stdint.h>
29+
30+
int32_t main()
31+
{
32+
${INSTRUCTION_SET_INTRINSIC};
33+
return 0;
34+
}")
35+
36+
set(CMAKE_REQUIRED_FLAGS "${INSTRUCTION_SET_IN_FLAG}")
37+
set(CHECK_RESULT_VAR "${INSTRUCTION_SET_NAME}")
38+
CHECK_CXX_SOURCE_RUNS("${INSTRUCTION_SET_CODE}" "JSONIFIER-${CHECK_RESULT_VAR}")
39+
if(JSONIFIER-${CHECK_RESULT_VAR})
40+
set(${INSTRUCTION_SET_NAME} "${INSTRUCTION_SET_OUT_FLAG}" PARENT_SCOPE)
41+
list(APPEND JSONIFIER_CPU_INSTRUCTIONS "${INSTRUCTION_SET_NAME}")
42+
string(REPLACE ";" "," JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS}")
43+
set(JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS}" PARENT_SCOPE)
44+
else()
45+
message(STATUS "Instruction set ${INSTRUCTION_SET_NAME} not supported.")
46+
return()
47+
endif()
48+
endfunction()
49+
50+
set(INSTRUCTION_SET_NAMES "POPCNT" "LZCNT" "BMI" "AVX" "AVX2" "AVX512")
51+
set (INSTRUCTION_SET_CODE
52+
"auto result = _mm_popcnt_u64(uint64_t{})"
53+
"auto result = _lzcnt_u64(int64_t{})"
54+
"auto result = _blsr_u64(uint64_t{})"
55+
"auto result = _mm_castsi128_pd(__m128i{}).auto result02 = _mm_setzero_si128()"
56+
"auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
57+
"auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).auto result03 = _mm_abs_epi64 (__m128i{})"
58+
)
59+
60+
set(INDEX_SET "0" "1" "2" "3" "4" "5")
61+
62+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
63+
set(INSTRUCTION_SET_IN_FLAGS "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX2" "/arch:AVX512")
64+
set(INSTRUCTION_SET_OUT_FLAGS "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX2" "/arch:AVX512")
65+
else()
66+
set(INSTRUCTION_SET_IN_FLAGS "-march=native" "-march=native" "-march=native" "-march=native" "-march=native" "-march=native")
67+
set(INSTRUCTION_SET_OUT_FLAGS "-mpopcnt" "-mlzcnt" "-mbmi" "-mavx.-mpclmul" "-mavx2.-mpclmul" "-mavx512f.-mavx512bw.-mavx512vl.-mpclmul")
68+
endif()
69+
70+
set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")
71+
72+
if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64"))
73+
74+
foreach(CURRENT_INDEX IN LISTS INDEX_SET)
75+
list(GET INSTRUCTION_SET_NAMES "${CURRENT_INDEX}" INSTRUCTION_SET_NAME)
76+
list(GET INSTRUCTION_SET_CODE "${CURRENT_INDEX}" INSTRUCTION_SET_INTRINSIC)
77+
list(GET INSTRUCTION_SET_IN_FLAGS "${CURRENT_INDEX}" INSTRUCTION_SET_IN_FLAG)
78+
list(GET INSTRUCTION_SET_OUT_FLAGS "${CURRENT_INDEX}" INSTRUCTION_SET_OUT_FLAG)
79+
string(REPLACE "." ";" INSTRUCTION_SET_OUT_FLAG "${INSTRUCTION_SET_OUT_FLAG}")
80+
string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
81+
jsonifier_check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_IN_FLAG}" "${INSTRUCTION_SET_OUT_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
82+
endforeach()
83+
84+
message(STATUS "Detected CPU Architecture: ${JSONIFIER_CPU_INSTRUCTIONS}")
85+
else()
86+
message(STATUS "SSE not supported by architecture ${CMAKE_SYSTEM_PROCESSOR}")
87+
endif()
88+
89+
set(AVX_FLAG)
90+
set(JSONIFIER_CPU_INSTRUCTIONS 0)
91+
92+
if (NOT "${POPCNT}" STREQUAL "")
93+
list(APPEND AVX_FLAG "${POPCNT}")
94+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 0" OUTPUT_FORMAT DECIMAL)
95+
endif()
96+
if (NOT "${LZCNT}" STREQUAL "")
97+
list(APPEND AVX_FLAG "${LZCNT}")
98+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 1" OUTPUT_FORMAT DECIMAL)
99+
endif()
100+
if (NOT "${BMI}" STREQUAL "")
101+
list(APPEND AVX_FLAG "${BMI}")
102+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 2" OUTPUT_FORMAT DECIMAL)
103+
endif()
104+
if (NOT "${AVX512}" STREQUAL "")
105+
list(APPEND AVX_FLAG "${AVX512}")
106+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 5" OUTPUT_FORMAT DECIMAL)
107+
elseif (NOT "${AVX2}" STREQUAL "")
108+
list(APPEND AVX_FLAG "${AVX2}")
109+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 4" OUTPUT_FORMAT DECIMAL)
110+
elseif (NOT "${AVX}" STREQUAL "")
111+
list(APPEND AVX_FLAG "${AVX}")
112+
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 3" OUTPUT_FORMAT DECIMAL)
113+
endif()
114+
115+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}")

0 commit comments

Comments
 (0)