View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0000357 | mercury | Bug | public | 2014-09-02 16:05 | 2016-10-03 10:58 | ||||
Reporter | juliensf | ||||||||
Assigned To | juliensf | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Platform | x86_64 | OS | OS X | OS Version | 10.9 | ||||
Product Version | |||||||||
Target Version | 15.11 | Fixed in Version | |||||||
Summary | 0000357: Parallel conjunction broken on OS X | ||||||||
Description | Parallel conjunctions are broken on OS X (I used asm_fast.par.gc, but this presumably applies to the other grades as well), because although OS X defines the function sem_init (called from mercury_context.c), it defines it to only return an error. Possible solutions to this are either to use named semaphores, e.g. with sem_open, or to use Grand Central Dispatch. (I'm not sure how well the latter would work with GCC though.) | ||||||||
Tags | No tags attached. | ||||||||
Attached Files |
|
Notes | |
wangp (developer) 2014-09-02 16:24 |
Or just condition variables, though presumably they perform worse so we would want to stick to semaphores on better platforms. |
juliensf (administrator) 2014-09-02 16:25 |
This would have shown up more obviously had the return value of sem_init been checked! There are also a bunch of calls to various pthread_* functions in the runtime, for example pthread_mutex_init and pthread_attr_init, where the return values are not checked. |
pbone (administrator) 2016-09-29 14:04 |
I remember some things about writing this code but not others. In particular I remember choosing semaphores for a very good reason, but I don't remember what that reason was :-( I'm not sure what should be used instead on OS X. Except that if we want to use GCD, then we should essentially write a different implementation for the N:M threading on OS X, as GCD will (and should) handle this for us. I suspect windows is a similar case as it supports fibers. However that's about all I know of either platform/API. So I'd recommend trying to replace this with named semaphores, if those are supported/work, or maybe condition variables - again there's a good reason why I didn't use those but I don't know what it is. And in the longer term consider writing an alternative implementation of all this code (maybe keep the work stealing) for OS X. |
juliensf (administrator) 2016-09-29 14:13 |
Hi Paul, Using GCD to do the N:M threading is a separate issue; the semaphore implementation in libdispatch is close enough to POSIX unnamed semaphores that it should be easy enough to use as a drop-in replacement. Using GCD in general on OS X is a much larger change. |
pbone (administrator) 2016-09-29 14:24 |
Agreed, which is why I said that's a longer term change, and by implication not really part of this bug. However I wasn't aware of the primitives provided by libdispatch so I didn't know that's what you meant when you said GCD. It sounds reasonable to me. |
juliensf (administrator) 2016-10-03 10:58 |
Fixed in commit 1fc495c. |
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2014-09-02 16:05 | juliensf | New Issue | |
2014-09-02 16:24 | wangp | Note Added: 0000779 | |
2014-09-02 16:25 | juliensf | Note Added: 0000780 | |
2015-10-21 10:40 | pbone | Target Version | => 15.11 |
2016-09-29 11:37 | juliensf | Assigned To | => juliensf |
2016-09-29 11:37 | juliensf | Status | new => assigned |
2016-09-29 14:04 | pbone | Note Added: 0000921 | |
2016-09-29 14:13 | juliensf | Note Added: 0000922 | |
2016-09-29 14:24 | pbone | Note Added: 0000923 | |
2016-10-03 10:58 | juliensf | Status | assigned => resolved |
2016-10-03 10:58 | juliensf | Resolution | open => fixed |
2016-10-03 10:58 | juliensf | Note Added: 0000925 |