rdicosmo / parmap

Parmap is a minimalistic library allowing to exploit multicore architecture for OCaml programs with minimal modifications.
http://rdicosmo.github.io/parmap/
Other
94 stars 20 forks source link

test floatscale and simplescale fail on 32bit #92

Closed olafhering closed 3 years ago

olafhering commented 4 years ago

dune runtest fails on i586 devel:languages:ocaml/ocaml-parmap. The result of Array.make is too large. A quick change like that helps, but then it crashes with SIGSEGV:

--- a/tests/floatscale.ml
+++ b/tests/floatscale.ml
@@ -30,7 +30,11 @@ let env_string = env_param (fun x -> x)

 let nIters = env_int "nIters" 1

-let nData = env_int "nData" 10000000
+let nData_default =
+  let default = 10000000 in
+  if default > Sys.max_array_length / 2 then Sys.max_array_length / 2 else default
+
+let nData = env_int "nData" nData_default

 let nProcs = env_int "nProcs" 8
[    2s] Running[13]: (cd _build/default/tests && ./floatscale.exe)
[    4s] Command [13] got signal SEGV:
[    4s] $ (cd _build/default/tests && ./floatscale.exe)
[    4s] nData 2097151
[    4s] Test: normal parmap
[    4s] Testing scalability with 1 iterations on 8 to 8 cores, step 1
[    4s] Sequential execution takes 0.353521 seconds
[    4s] Speedup with 8 cores (average on 1 iterations): 0.396299 (tseq=0.353521, tpar=0.892057)
[    4s] Test: specialised array parmap
[    4s] Testing scalability with 1 iterations on 8 to 8 cores, step 1
[    4s] Sequential execution takes 0.175939 seconds
[    4s] Speedup with 8 cores (average on 1 iterations): 0.872372 (tseq=0.175939, tpar=0.201679)
[    4s] Test: specialised float array parmap
[    4s] Testing scalability with 1 iterations on 8 to 8 cores, step 1
[    4s] Sequential execution takes 0.122668 seconds
UnixJunkie commented 4 years ago

Is this error due to the switch to dune?

olafhering commented 4 years ago

Unlikely. The docs state the Array.make size is limited, and with floats the size has to be even smaller. But if nProc and nData is reduced the tests fail anyway. I was under the impression that OCaml code can not cause memory overflow. Apparently it can crash anyway, there is even an invalid free().

I will take this opportunityl to improve my OCaml skills and debug it myself.

UnixJunkie commented 4 years ago

What is the make target that allows to reproduce your problem?

olafhering commented 4 years ago

What is the make target that allows to reproduce your problem?

make tests probably?

UnixJunkie commented 4 years ago
make tests
./floatscale.native
Test: normal parmap
Testing scalability with 1 iterations on 8 to 8 cores, step 1
Sequential execution takes 1.625651 seconds
Speedup with 8 cores (average on 1 iterations): 0.237331 (tseq=1.625651, tpar=6.849722)
Test: specialised array parmap
Testing scalability with 1 iterations on 8 to 8 cores, step 1
Sequential execution takes 0.496369 seconds
Speedup with 8 cores (average on 1 iterations): 0.588940 (tseq=0.496369, tpar=0.842817)
Test: specialised float array parmap
Testing scalability with 1 iterations on 8 to 8 cores, step 1
Sequential execution takes 0.283572 seconds
Speedup with 8 cores (average on 1 iterations): 1.302353 (tseq=0.283572, tpar=0.217738)

No problems with 64 bits, at least. Good luck with the debugging.

rdicosmo commented 3 years ago

This should now be solved with the release 1.2.1