Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
7d920198
Commit
7d920198
authored
Dec 15, 2011
by
Simon Marlow
Browse files
add a test for setNumCapabilities
parent
0fc8eeb4
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/concurrent/should_run/all.T
View file @
7d920198
...
...
@@ -210,3 +210,7 @@ test('conc067', ignore_output, compile_and_run, [''])
# than one CPU.
test
('
conc068
',
[
omit_ways
('
threaded2
'),
exit_code
(
1
)
],
compile_and_run
,
[''])
test
('
setnumcapabilities001
',
[
only_ways
(['
threaded1
','
threaded2
']),
extra_run_opts
('
4 12 2000
')
],
compile_and_run
,
[''])
testsuite/tests/concurrent/should_run/setnumcapabilities001.hs
0 → 100644
View file @
7d920198
import
GHC.Conc
import
Control.Parallel
import
Control.Parallel.Strategies
import
System.Environment
import
System.IO
import
Control.Monad
import
Text.Printf
import
Data.Time.Clock
main
=
do
[
n
,
q
,
t
]
<-
fmap
(
fmap
read
)
getArgs
forkIO
$
do
forM_
(
cycle
([
n
,
n
-
1
..
1
]
++
[
2
..
n
-
1
]))
$
\
m
->
do
setNumCapabilities
m
threadDelay
t
printf
"%d"
(
nqueens
q
)
nqueens
::
Int
->
Int
nqueens
nq
=
length
(
pargen
0
[]
)
where
safe
::
Int
->
Int
->
[
Int
]
->
Bool
safe
x
d
[]
=
True
safe
x
d
(
q
:
l
)
=
x
/=
q
&&
x
/=
q
+
d
&&
x
/=
q
-
d
&&
safe
x
(
d
+
1
)
l
gen
::
[[
Int
]]
->
[[
Int
]]
gen
bs
=
[
(
q
:
b
)
|
b
<-
bs
,
q
<-
[
1
..
nq
],
safe
q
1
b
]
pargen
::
Int
->
[
Int
]
->
[[
Int
]]
pargen
n
b
|
n
>=
threshold
=
iterate
gen
[
b
]
!!
(
nq
-
n
)
|
otherwise
=
concat
bs
where
bs
=
map
(
pargen
(
n
+
1
))
(
gen
[
b
])
`
using
`
parList
rdeepseq
threshold
=
3
testsuite/tests/concurrent/should_run/setnumcapabilities001.stdout
0 → 100644
View file @
7d920198
14200
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment