|Anonymous | Login | Signup for a new account||2014-03-10 19:41 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006121||OCaml||OCaml backend (code generation)||public||2013-08-06 16:20||2014-01-17 17:44|
|Priority||normal||Severity||minor||Reproducibility||have not tried|
|Target Version||4.01.1+dev||Fixed in Version|
|Summary||0006121: Atomic load primitives|
|Description||The mirage project has reported that they need to be able to load and store values using %caml_bigstring_(get/set)* primitives atomically.|
Since the addresses passed to thoses primitives can be non aligned, on architectures that does not support unaligned access, those primitives are implemented as byte by byte reads.
There are two possibilities:
* either add %caml_atomic_bigstring_(get/set)* primitives that can fail on non-aligned access
* change the implementation to something like
if addr is aligned
else fallback to byte by byte read
the guaranty of atomicity is lifted on unaligned load since it is impossible to ensure.
The patch propose a way to implement a reasonably efficient version of that (only shown for 32 bit load). This is probably always faster than byte by byte read.
|Attached Files||0001-atomic-32-bit-load.patch [^] (3,774 bytes) 2013-08-06 16:20 [Show Content]|
|Of course if any solution is chosen, I can propose a full patch for it.|
Our specific use-case is to satisfy existing shared memory protocols in Xen, for example vchan: https://github.com/mirage/ocaml-vchan/blob/master/lib/vchan_stubs.c [^]
These use the gcc atomic builtins: http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Atomic-Builtins.html [^]
Since these atomicops are showing more often in lock-free data structures, it might be better for OCaml to provide explicit equivalent primops to them that libraries can use, rather than having more ambiguous modes such as the Bigarray "fallback to byte-by-byte" proposal above. For now, we're just using C bindings as shown in the link above.
|2013-08-06 16:20||chambart||New Issue|
|2013-08-06 16:20||chambart||File Added: 0001-atomic-32-bit-load.patch|
|2013-08-06 16:21||chambart||Note Added: 0010127|
|2013-08-19 17:22||doligez||Status||new => acknowledged|
|2013-08-19 17:22||doligez||Target Version||=> 4.01.1+dev|
|2013-10-10 11:49||avsm||Note Added: 0010447|
|2013-10-28 15:52||shinwell||Assigned To||=> shinwell|
|2013-10-28 15:52||shinwell||Status||acknowledged => assigned|
|2014-01-17 17:44||doligez||Tag Attached: patch|
|Copyright © 2000 - 2011 MantisBT Group|