Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
09a46078
Commit
09a46078
authored
Jun 19, 2008
by
Jakub Jelinek
Committed by
Jakub Jelinek
Jun 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* testsuite/libgomp.c/nqueens-1.c: New test.
From-SVN: r136942
parent
f30cfcb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
libgomp/ChangeLog
+4
-0
libgomp/testsuite/libgomp.c/nqueens-1.c
+66
-0
No files found.
libgomp/ChangeLog
View file @
09a46078
2008-06-19 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c/nqueens-1.c: New test.
2008-06-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
2008-06-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* configure: Regenerate.
* configure: Regenerate.
...
...
libgomp/testsuite/libgomp.c/nqueens-1.c
0 → 100644
View file @
09a46078
/* { dg-do run } */
/* { dg-options "-O2 -fopenmp" } */
/* { dg-require-effective-target tls_runtime } */
#include <omp.h>
#include <stdio.h>
#include <string.h>
int
cnt
;
#pragma omp threadprivate (cnt)
void
nqueens
(
char
*
a
,
int
n
,
int
pos
)
{
/* b[i] = j means the queen in i-th row is in column j. */
char
b
[
pos
+
1
];
int
i
,
j
;
memcpy
(
b
,
a
,
pos
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
j
=
0
;
j
<
pos
;
j
++
)
if
(
b
[
j
]
==
i
||
b
[
j
]
==
i
+
pos
-
j
||
i
==
b
[
j
]
+
pos
-
j
)
break
;
if
(
j
<
pos
)
continue
;
if
(
pos
==
n
-
1
)
/* Found a solution. Could output it here. */
++
cnt
;
else
{
b
[
pos
]
=
i
;
#pragma omp task
nqueens
(
b
,
n
,
pos
+
1
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
n
=
8
;
if
(
argc
>=
2
)
n
=
strtoul
(
argv
[
1
],
NULL
,
0
);
if
(
n
<
1
||
n
>
127
)
{
fprintf
(
stderr
,
"invalid count %d
\n
"
,
n
);
return
1
;
}
cnt
=
0
;
double
stime
=
omp_get_wtime
();
nqueens
(
""
,
n
,
0
);
printf
(
"serial N %d solutions # %d time %f
\n
"
,
n
,
cnt
,
omp_get_wtime
()
-
stime
);
#pragma omp parallel
cnt
=
0
;
stime
=
omp_get_wtime
();
int
tempcnt
=
0
;
#pragma omp parallel reduction (+:tempcnt)
{
#pragma omp single
nqueens
(
""
,
n
,
0
);
tempcnt
=
cnt
;
}
cnt
=
tempcnt
;
printf
(
"parallel N %d solutions # %d time %f
\n
"
,
n
,
cnt
,
omp_get_wtime
()
-
stime
);
return
0
;
}
Write
Preview
Markdown
is supported
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