Opened 9 years ago

Closed 14 months ago

#4442 closed feature request (fixed)

Add unaligned version of indexWordArray#

Reported by: tibbe Owned by: reinerp
Priority: low Milestone:
Component: Compiler Version: 7.1
Keywords: Cc: duncan, sjakobi
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: #14447 Differential Rev(s): Phab:D4488
Wiki Page:

Description (last modified by igloo)

indexWordArray# takes an offset in whole words, making it impossible to do unaligned reads on platforms that support such reads. This has performance implications for some programs e.g. implementations of MurmurHash.

I propose we add versions of indexWord*Array that take byte offsets. The user is responsible for only using those on platforms that support them and the implementation is free to crash if they're used elsewhere.

Change History (20)

comment:1 Changed 9 years ago by simonmar

As per discussion on glasgow-haskell-users, this can be done with a combination of byteArrayContents#, plusAddr#, indexWordOffAddr#, and touch#. Does that work well enough for your purposes?

comment:2 in reply to:  1 Changed 9 years ago by tibbe

Replying to simonmar:

As per discussion on glasgow-haskell-users, this can be done with a combination of byteArrayContents#, plusAddr#, indexWordOffAddr#, and touch#. Does that work well enough for your purposes?

That only works if the array is pinned.

Simon suggested that we could replace the current primops with ones that take byte offsets and implement the current set of primops in terms of these, new primops.

comment:3 Changed 9 years ago by igloo

Description: modified (diff)

comment:4 Changed 9 years ago by igloo

Milestone: 7.2.1

comment:5 Changed 8 years ago by igloo

Milestone: 7.4.17.6.1
Priority: normallow

comment:6 Changed 7 years ago by igloo

Milestone: 7.6.17.6.2

comment:7 Changed 5 years ago by tibbe

Cc: duncan added
difficulty: Unknown

comment:8 Changed 5 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:9 Changed 5 years ago by thoughtpolice

Component: libraries (other)Core Libraries
Owner: set to ekmett

Moving over to new owning component 'Core Libraries'.

comment:10 Changed 5 years ago by thomie

Component: Core LibrariesCompiler
Type of failure: None/UnknownRuntime performance bug

comment:11 Changed 5 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:12 Changed 4 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:13 Changed 4 years ago by thomie

Owner: ekmett deleted

comment:14 Changed 4 years ago by thomie

Milestone: 8.0.1

comment:15 Changed 23 months ago by hvr

I just marked #14447 as a duplicate of this one

comment:16 Changed 23 months ago by hvr

comment:17 Changed 19 months ago by reinerp

Owner: set to reinerp

comment:18 Changed 19 months ago by sjakobi

Cc: sjakobi added

comment:19 Changed 18 months ago by David Feuer <David.Feuer@…>

In efd70cfb/ghc:

Add unaligned bytearray access primops. Fixes #4442.

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #4442

Differential Revision: https://phabricator.haskell.org/D4488

comment:20 Changed 14 months ago by thomie

Differential Rev(s): Phab:D4488
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.