Ticket #7067 (closed feature request: fixed)

Opened 11 months ago

Last modified 10 months ago

Add alignment-restricted ForeignPtr allocation actions

Reported by: nicolast Owned by: simonmar
Priority: normal Milestone: 7.6.1
Component: libraries/base Version:
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Whilst GHC.ForeignPtr? exports some actions to allocate buffers containing an element of some type, or of some specific byte-length efficiently, and there's an implementation of newAlignedPinnedByteArray# used internally, there's no way to request such buffer of a given size and at a given alignment.

The ability to enforce a specific alignment for some memory buffer is important e.g. when working with SIMD instructions (which is my original use-case). My attempts to work-around the lack of this function failed miserably (with a reproducible test-case) as mentioned in [1].

[1]  http://www.haskell.org/pipermail/glasgow-haskell-users/2012-July/022579.html

Attachments

0001-Add-alignment-restricted-ForeignPtr-allocation-actio.patch Download (2.8 KB) - added by nicolast 11 months ago.
Add alignment-restricted allocation actions to GHC.ForeignPtr?

Change History

Changed 11 months ago by nicolast

Add alignment-restricted allocation actions to GHC.ForeignPtr?

Changed 11 months ago by nicolast

  • status changed from new to patch

Using attachment:ticket:7067:0001-Add-alignment-restricted-ForeignPtr-allocation-actio.patch Download and an adapted mallocVector implementation (see mallocVectorMine3 at  https://gist.github.com/3084806#LC129) the corruption as found earlier (using mallocVectorMine1 or mallocVectorMine2) no longer occur.

Changed 10 months ago by simonmar

  • owner set to simonmar
  • difficulty set to Unknown
  • milestone set to 7.6.1

Patch looks good to me.

Changed 10 months ago by simonmar

  • status changed from patch to closed
  • resolution set to fixed

Applied, thanks!

Note: See TracTickets for help on using tickets.