Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
bf944c0e
Commit
bf944c0e
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
fix some timing bugs with the parallel particle sort.
Former-commit-id: c258689b9f119467d89135048c68fd24d65261dc
parent
a5349e84
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/space.c
+8
-4
8 additions, 4 deletions
src/space.c
with
8 additions
and
4 deletions
src/space.c
+
8
−
4
View file @
bf944c0e
...
...
@@ -343,9 +343,10 @@ void space_rebuild ( struct space *s , double cell_max ) {
void
parts_sort
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
int
*
ind
,
int
N
,
int
min
,
int
max
)
{
struct
{
int
i
,
j
,
min
,
max
,
ready
;
int
i
,
j
,
min
,
max
;
volatile
int
ready
;
}
qstack
[
space_qstack
];
volatile
int
first
,
last
,
waiting
;
volatile
unsigned
int
first
,
last
,
waiting
;
int
pivot
;
int
i
,
ii
,
j
,
jj
,
temp_i
,
qid
;
...
...
@@ -363,7 +364,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
first
=
0
;
last
=
1
;
waiting
=
1
;
/* Parallel bit. */
#pragma omp parallel default(
share
d) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_xp,temp_p)
#pragma omp parallel default(
none) shared(first,last,waiting,qstack,parts,xparts,in
d) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_xp,temp_p)
{
/* Main loop. */
...
...
@@ -374,7 +375,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
qid
=
atomic_inc
(
&
first
)
%
space_qstack
;
/* Wait for the interval to be ready. */
while
(
waiting
>
0
&&
atomic_cas
(
&
qstack
[
qid
].
ready
,
1
,
0
)
!=
1
);
while
(
waiting
>
0
&&
atomic_cas
(
&
qstack
[
qid
].
ready
,
1
,
1
)
!=
1
);
/* Broke loop for all the wrong reasons? */
if
(
waiting
==
0
)
...
...
@@ -385,6 +386,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
j
=
qstack
[
qid
].
j
;
min
=
qstack
[
qid
].
min
;
max
=
qstack
[
qid
].
max
;
qstack
[
qid
].
ready
=
0
;
// printf( "parts_sort_par: thread %i got interval [%i,%i] with values in [%i,%i].\n" , omp_get_thread_num() , i , j , min , max );
/* Loop over sub-intervals. */
...
...
@@ -425,6 +427,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
/* Recurse on the left? */
if
(
jj
>
i
&&
pivot
>
min
)
{
qid
=
atomic_inc
(
&
last
)
%
space_qstack
;
while
(
atomic_cas
(
&
qstack
[
qid
].
ready
,
0
,
0
)
!=
0
);
qstack
[
qid
].
i
=
i
;
qstack
[
qid
].
j
=
jj
;
qstack
[
qid
].
min
=
min
;
...
...
@@ -448,6 +451,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
/* Recurse on the right? */
if
(
jj
+
1
<
j
&&
pivot
+
1
<
max
)
{
qid
=
atomic_inc
(
&
last
)
%
space_qstack
;
while
(
atomic_cas
(
&
qstack
[
qid
].
ready
,
0
,
0
)
!=
0
);
qstack
[
qid
].
i
=
jj
+
1
;
qstack
[
qid
].
j
=
j
;
qstack
[
qid
].
min
=
pivot
+
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment