ObjFW  Check-in [e7465cd688]

Overview
Comment:OFSystemInfo: Remove check for SSE support in OS

The check was wrong and would return false on OSes that are SSE-enabled
but not AVX-enabled.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e7465cd688e000c94700758fcfb07a8a795aab9e72a920a6fe37d494d28a7e2e
User & Date: js on 2023-11-10 01:31:40
Other Links: manifest | tags
Context
2023-12-21
15:22
OFSystemInfo: Check if the OS enabled SSE support check-in: 1f26898324 user: js tags: trunk
2023-11-10
01:31
OFSystemInfo: Remove check for SSE support in OS check-in: e7465cd688 user: js tags: trunk
00:25
OFSystemInfo: Check OS support for SSE/AVX/AVX512 check-in: 42efa8c05a user: js tags: trunk
Changes

Modified src/OFSystemInfo.h from [e1f6b5972e] to [721a4a4cb5].

234
235
236
237
238
239
240
241



242
243
244
245

246
247
248
249
250



251
252
253
254

255
256
257
258
259



260
261
262
263

264
265
266
267
268



269
270
271
272

273
274
275
276
277



278
279
280
281

282
283
284
285
286



287
288
289
290

291
292
293
294
295
296
297
234
235
236
237
238
239
240

241
242
243
244
245
246

247
248
249
250
251

252
253
254
255
256
257

258
259
260
261
262

263
264
265
266
267
268

269
270
271
272
273

274
275
276
277
278
279

280
281
282
283
284

285
286
287
288
289
290

291
292
293
294
295

296
297
298
299
300
301

302
303
304
305
306
307
308
309







-
+
+
+



-
+




-
+
+
+



-
+




-
+
+
+



-
+




-
+
+
+



-
+




-
+
+
+



-
+




-
+
+
+



-
+







 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU supports enhanced 3DNow!
 */
+ (bool)supportsEnhanced3DNow;

/**
 * @brief Returns whether the CPU and OS support SSE.
 * @brief Returns whether the CPU supports SSE.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSE
 * @return Whether the CPU supports SSE
 */
+ (bool)supportsSSE;

/**
 * @brief Returns whether the CPU and OS support SSE2.
 * @brief Returns whether the CPU supports SSE2.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSE2
 * @return Whether the CPU supports SSE2
 */
+ (bool)supportsSSE2;

/**
 * @brief Returns whether the CPU and OS support SSE3.
 * @brief Returns whether the CPU supports SSE3.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSE3
 * @return Whether the CPU supports SSE3
 */
+ (bool)supportsSSE3;

/**
 * @brief Returns whether the CPU and OS support SSSE3.
 * @brief Returns whether the CPU supports SSSE3.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSSE3
 * @return Whether the CPU supports SSSE3
 */
+ (bool)supportsSSSE3;

/**
 * @brief Returns whether the CPU and OS support SSE4.1.
 * @brief Returns whether the CPU supports SSE4.1.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSE4.1
 * @return Whether the CPU supports SSE4.1
 */
+ (bool)supportsSSE41;

/**
 * @brief Returns whether the CPU and OS support SSE4.2.
 * @brief Returns whether the CPU supports SSE4.2.
 *
 * @note This only checks CPU support and assumes OS support!
 *
 * @note This method is only available on AMD64 and x86.
 *
 * @return Whether the CPU and OS support SSE4.2
 * @return Whether the CPU supports SSE4.2
 */
+ (bool)supportsSSE42;

/**
 * @brief Returns whether the CPU and OS support AVX.
 *
 * @note This method is only available on AMD64 and x86.

Modified src/OFSystemInfo.m from [dde9f4593e] to [81b1425388].

773
774
775
776
777
778
779
780

781
782
783
784
785
786

787
788
789
790
791
792

793
794
795
796
797
798

799
800
801
802
803
804

805
806
807
808
809
810

811
812
813
814
815
816
817

818
819
820
821
822
823

824
825
826
827
828
829
830
773
774
775
776
777
778
779

780

781
782
783
784

785

786
787
788
789

790

791
792
793
794

795

796
797
798
799

800

801
802
803
804

805

806
807
808
809
810

811
812
813
814
815
816

817
818
819
820
821
822
823
824







-
+
-




-
+
-




-
+
-




-
+
-




-
+
-




-
+
-





-
+





-
+







{
	return (x86CPUID(0x80000000, 0).eax >= 0x80000001 &&
	    x86CPUID(0x80000001, 0).edx & (1u << 30));
}

+ (bool)supportsSSE
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 25)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 25));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsSSE2
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 26)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 26));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsSSE3
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 0)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 0));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsSSSE3
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 9)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 9));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsSSE41
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 19)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 19));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsSSE42
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 20)) &&
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 20));
	    x86XCR(0).eax & (1u << 1));
}

+ (bool)supportsAVX
{
	return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 28)) &&
	    x86XCR(0).eax & (1u << 2));
	    (x86XCR(0).eax & 0x6) == 0x6);
}

+ (bool)supportsAVX2
{
	return ((x86CPUID(0, 0).eax >= 7 && (x86CPUID(7, 0).ebx & (1u << 5))) &&
	    x86XCR(0).eax & (1u << 2));
	    (x86XCR(0).eax & 0x6) == 0x6);
}

+ (bool)supportsAESNI
{
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 25));
}

842
843
844
845
846
847
848
849

850
851
852
853
854
855

856
857
858
859
860
861

862
863
864
865
866
867

868
869
870
871
872
873

874
875
876
877
878
879

880
881
882
883
884
885

886
887
888
889
890
891

892
893
894
895
896
897

898
899
900
901
902
903

904
905
906
907
908
909

910
911
912
913
914
915

916
917
918
919
920
921

922
923
924
925
926
927

928
929
930
931
932
933

934
935
936
937
938
939
940
836
837
838
839
840
841
842

843
844
845
846
847
848

849
850
851
852
853
854

855
856
857
858
859
860

861
862
863
864
865
866

867
868
869
870
871
872

873
874
875
876
877
878

879
880
881
882
883
884

885
886
887
888
889
890

891
892
893
894
895
896

897
898
899
900
901
902

903
904
905
906
907
908

909
910
911
912
913
914

915
916
917
918
919
920

921
922
923
924
925
926

927
928
929
930
931
932
933
934







-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+





-
+







{
	return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 29));
}

+ (bool)supportsAVX512Foundation
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 16)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512ConflictDetectionInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 28)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512ExponentialAndReciprocalInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 27)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512PrefetchInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 26)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512VectorLengthExtensions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 31)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512DoublewordAndQuadwordInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 17)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512ByteAndWordInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 30)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512IntegerFusedMultiplyAdd
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 21)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512VectorByteManipulationInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 1)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512VectorPopulationCountInstruction
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 14)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512VectorNeuralNetworkInstructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 11)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512VectorByteManipulationInstructions2
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 6)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512BitAlgorithms
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 12)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512Float16Instructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).edx & (1u << 23)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}

+ (bool)supportsAVX512BFloat16Instructions
{
	return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 1).eax & (1u << 5)) &&
	    x86XCR(0).eax & ((1u << 5) | (1u << 6) | (1u << 7)));
	    (x86XCR(0).eax & 0xE6) == 0xE6);
}
#endif

#if defined(OF_POWERPC) || defined(OF_POWERPC64)
+ (bool)supportsAltiVec
{
# if defined(OF_MACOS)