[GHC] #12573: Allow the user to pick the address that the RTS reserves for the heap

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Runtime | Version: 8.0.1 System | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- We stumbled upon a case where an external library (OpenCL) does not work if a specific address (0x200000000) is taken. It so happens that `osReserveHeapMemory` starts trying to `mmap` at `0x200000000`: {{{ void *hint = (void*)((W_)8 * (1 << 30) + attempt * BLOCK_SIZE); at = osTryReserveHeapMemory(*len, hint); }}} This makes it impossible to use Haskell programs compiled with GHC 8 with C functions that use OpenCL. See this example https://github.com/chpatrick/oclwtf for a repro. My proposal is to allow the user to work around this kind of behavior outside our control by letting the user override the starting address through an RTS command line flag. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * cc: trevor.mcdonell@…, chak (added) Comment: A similar issue came up with Accelerate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tmcdonell): @bitonic my current (partially working) solution is to use an `__attribute__((constructor))` function to `mmap` the region that CUDA/OpenCL requires before the RTS initialises. The RTS will then avoid it and you can `munmap` it right before initialising CUDA/OpenCL: https://github.com/tmcdonell/cuda/blob/hotfix/ghc-8/cbits/init.c You can also initialise OpenCL directly in the constructor function, but then you'll spin up the GPU many times during compilation/haddock (every time a package loads your library). (This is simpler and what the master branch of the above repo does, actually.) Both those approaches work for compiled programs, but not in ghci, and I haven't had a chance to dig to the bottom of it yet. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by tmcdonell): * cc: trevor.mcdonell@… (removed) * cc: tmcdonell (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bitonic): @tmcdonell , that's clever, I did not know about `__attribute__((constructor))`. It's a nice workaround until we get the RTS workaround. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => closed * resolution: => fixed Comment: Hadn't noticed that the ticket wasn't set on the phabricator diff correctly before I committed. In any case, committed as 1b5f9207a649a64a1bba20b0283253425f9208d7 Thanks for the report and fix bitonic! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: merge Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: closed => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12573: Allow the user to pick the address that the RTS reserves for the heap -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Comment: Merged to `ghc-8.0` as 658f0354326ddfdafec3772cdb86d89f0e424663. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12573#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC