Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006121OCamlOCaml backend (code generation)public2013-08-06 16:202014-07-17 11:22
Reporterchambart 
Assigned Toshinwell 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version4.03.0+devFixed in Version 
Summary0006121: Atomic load primitives
DescriptionThe 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
  then read_one_word
  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.
Tagspatch
Attached Filespatch file icon 0001-atomic-32-bit-load.patch [^] (3,774 bytes) 2013-08-06 16:20 [Show Content]

- Relationships

-  Notes
(0010127)
chambart (developer)
2013-08-06 16:21

Of course if any solution is chosen, I can propose a full patch for it.
(0010447)
avsm (reporter)
2013-10-10 11:49

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.

- Issue History
Date Modified Username Field Change
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
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-17 11:22 shinwell Target Version 4.02.0+dev => 4.03.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker