core_unix
core_unix copied to clipboard
time stamp counter does not work on ARM64
Uncaught exception:
(Invalid_argument
"Float.iround_nearest_exn: argument (nan) is too small or NaN")
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Base__Float.iround_nearest_exn_64 in file "src/float.ml" (inlined), line 360, characters 4-89
Called from Base__Float.int63_round_nearest_arch64_noalloc_exn in file "src/float.ml", line 514, characters 60-82
Called from Time_stamp_counter.Calibrator.calibrate_using in file "time_stamp_counter/src/time_stamp_counter.ml" (inlined), line 277, characters 7-69
Called from Time_stamp_counter.Calibrator.initialize.(fun) in file "time_stamp_counter/src/time_stamp_counter.ml", line 285, characters 6-56
Called from Base__List0.iter in file "src/list0.ml", line 60, characters 4-7
Called from Time_stamp_counter.Calibrator.create_using in file "time_stamp_counter/src/time_stamp_counter.ml", line 322, characters 4-24
I can also repro on my Rockchip RK3399 (Aarch64, Linux), same issue
# Time_stamp_counter.(now () |> to_time_ns ~calibrator:(Lazy.force calibrator));;
Exception:
Invalid_argument
"Float.iround_nearest_exn: argument (nan) is too small or NaN".
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Base__Float.int63_round_nearest_arch64_noalloc_exn in file "src/float.ml", line 514, characters 60-82
Called from Time_stamp_counter.Calibrator.calibrate_using in file "time_stamp_counter/src/time_stamp_counter.ml", line 277, characters 7-69
Called from Base__List0.iter in file "src/list0.ml", line 60, characters 4-7
Called from Time_stamp_counter.Calibrator.create_using in file "time_stamp_counter/src/time_stamp_counter.ml", line 322, characters 4-24
Called from CamlinternalLazy.do_force_block in file "camlinternalLazy.ml", line 49, characters 17-27
Re-raised at CamlinternalLazy.do_force_block in file "camlinternalLazy.ml", line 56, characters 4-11
Called from unknown location
Called from Topeval.load_lambda in file "toplevel/byte/topeval.ml", line 89, characters 4-14
Ok, found it, this is due to:
# Ocaml_intrinsics.Perfmon.rdtsc ();;
- : int64 = 0L
Indeed this is not implemented for ARM. I guess, either implement the ARM version of rdtsc in ocaml_intrinsics would fix it.
See https://github.com/janestreet/ocaml_intrinsics/pull/7