File tree Expand file tree Collapse file tree 5 files changed +54
-4
lines changed Expand file tree Collapse file tree 5 files changed +54
-4
lines changed Original file line number Diff line number Diff line change
1
+ ; Helpers
2
+
3
+ (library
4
+ (name simd_test_helpers)
5
+ (wrapped false)
6
+ (modules test_helpers))
7
+
1
8
; Stubs
2
9
3
10
(foreign_library
12
19
(executables
13
20
(names basic ops arrays scalar_ops)
14
21
(modules basic ops arrays scalar_ops)
22
+ (libraries simd_test_helpers)
15
23
(foreign_archives stubs)
16
24
(ocamlopt_flags
17
25
(:standard -extension simd)))
118
126
consts_internal
119
127
arrays_internal
120
128
scalar_ops_internal)
129
+ (libraries simd_test_helpers)
121
130
(enabled_if
122
131
(<> %{system} macosx))
123
132
(foreign_archives stubs)
Original file line number Diff line number Diff line change @@ -833,6 +833,7 @@ module Float32x4 = struct
833
833
[@@ noalloc] [@@ unboxed] [@@ builtin]
834
834
835
835
let () =
836
+ Test_helpers. run_if_not_under_rosetta2 ~f: (fun () ->
836
837
Float32. check_floats (fun f0 f1 ->
837
838
failmsg := (fun () -> Printf. printf " %f | %f\n %!" (Int32. float_of_bits f0) (Int32. float_of_bits f1));
838
839
let fv0 = Float32. to_float32x4 f0 f0 f1 f1 in
@@ -860,6 +861,7 @@ module Float32x4 = struct
860
861
eq (float32x4_low_int64 result) (float32x4_high_int64 result)
861
862
(float32x4_low_int64 expect) (float32x4_high_int64 expect)
862
863
);
864
+ )
863
865
;;
864
866
865
867
external dp : (int [@ untagged]) -> (t [@ unboxed]) -> (t [@ unboxed]) -> (t [@ unboxed]) = " caml_vec128_unreachable" " caml_sse41_float32x4_dp"
@@ -1036,6 +1038,7 @@ module Float64x2 = struct
1036
1038
[@@ noalloc] [@@ unboxed] [@@ builtin]
1037
1039
1038
1040
let () =
1041
+ Test_helpers. run_if_not_under_rosetta2 ~f: (fun () ->
1039
1042
Float64. check_floats (fun f0 f1 ->
1040
1043
failmsg := (fun () -> Printf. printf " %f | %f\n %!" f0 f1);
1041
1044
let fv0 = to_float64x2 f0 f0 in
@@ -1063,6 +1066,7 @@ module Float64x2 = struct
1063
1066
eq (float64x2_low_int64 result) (float64x2_high_int64 result)
1064
1067
(float64x2_low_int64 expect) (float64x2_high_int64 expect)
1065
1068
);
1069
+ )
1066
1070
;;
1067
1071
1068
1072
external dp : (int [@ untagged]) -> (t [@ unboxed]) -> (t [@ unboxed]) -> (t [@ unboxed]) = " caml_vec128_unreachable" " caml_sse41_float64x2_dp"
Original file line number Diff line number Diff line change @@ -44,9 +44,10 @@ module Int64 = struct
44
44
[@@ noalloc] [@@ unboxed] [@@ builtin]
45
45
46
46
let () =
47
- eq' (bit_deposit 3L 4L ) 0x4L ;
48
- eq' (bit_deposit 235L 522L ) 0xAL ;
49
- eq' (bit_extract 3L 4L ) 0x0L ;
50
- eq' (bit_extract 235L 522L ) 0x3L
47
+ Test_helpers. run_if_not_under_rosetta2 ~f: (fun () ->
48
+ eq' (bit_deposit 3L 4L ) 0x4L ;
49
+ eq' (bit_deposit 235L 522L ) 0xAL ;
50
+ eq' (bit_extract 3L 4L ) 0x0L ;
51
+ eq' (bit_extract 235L 522L ) 0x3L )
51
52
;;
52
53
end
Original file line number Diff line number Diff line change
1
+ type rosetta2_status =
2
+ | Unknown
3
+ | Off
4
+ | On
5
+
6
+ let get_rosetta2_status () =
7
+ let file_path = Filename. temp_file " ocaml-rosetta2" " sysctl" in
8
+ let command = Printf. sprintf " /usr/sbin/sysctl -n sysctl.proc_translated > %S 2> /dev/null" file_path in
9
+ let exit_code = Sys. command command in
10
+ match exit_code with
11
+ | 0 ->
12
+ begin try
13
+ let file_chan = open_in file_path in
14
+ let first_line = input_line file_chan in
15
+ match first_line with
16
+ | "0" -> Off
17
+ | "1" -> On
18
+ | _ -> Unknown
19
+ with _ ->
20
+ Unknown
21
+ end
22
+ | _ ->
23
+ Unknown
24
+
25
+ let run_if_not_under_rosetta2 ~f =
26
+ match get_rosetta2_status () with
27
+ | Unknown | On -> ()
28
+ | Off -> f ()
Original file line number Diff line number Diff line change
1
+ type rosetta2_status =
2
+ | Unknown
3
+ | Off
4
+ | On
5
+
6
+ val get_rosetta2_status : unit -> rosetta2_status
7
+
8
+ val run_if_not_under_rosetta2 : f :(unit -> unit ) -> unit
You can’t perform that action at this time.
0 commit comments