Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
e30390bd
Commit
e30390bd
authored
Feb 06, 2013
by
Pedro Gonnet
Browse files
fixed bug in particle sorting.
Former-commit-id: b818c905d7773fcc18b1362f505d5ce81583cf2f
parent
bb68b080
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/space.c
View file @
e30390bd
...
...
@@ -562,7 +562,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* Sort the parts according to their cells. */
// tic = getticks();
parts_sort
(
s
->
parts
,
ind
,
s
->
nr_parts
,
0
,
s
->
nr_cells
);
parts_sort
(
s
->
parts
,
ind
,
s
->
nr_parts
,
0
,
s
->
nr_cells
);
// printf( "space_rebuild: parts_sort took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
/* We no longer need the indices as of here. */
...
...
@@ -628,7 +628,7 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
for
(
i
=
1
;
i
<
N
;
i
++
)
if
(
ind
[
i
]
<
ind
[
i
-
1
]
)
{
temp_i
=
ind
[
i
];
temp_p
=
parts
[
j
];
temp_p
=
parts
[
i
];
for
(
j
=
i
;
j
>
0
&&
ind
[
j
-
1
]
>
temp_i
;
j
--
)
{
ind
[
j
]
=
ind
[
j
-
1
];
parts
[
j
]
=
parts
[
j
-
1
];
...
...
@@ -655,7 +655,7 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
}
/* Verify sort. */
for
(
int
k
=
0
;
k
<=
j
;
k
++
)
/*
for ( int k = 0 ; k <= j ; k++ )
if ( ind[k] > pivot ) {
printf( "parts_sort: sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i, N=%i.\n" , k , ind[k] , pivot , i , j , N );
error( "Sorting failed (<=pivot)." );
...
...
@@ -664,36 +664,15 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
if ( ind[k] <= pivot ) {
printf( "parts_sort: sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%i, j=%i, N=%i.\n" , k , ind[k] , pivot , i , j , N );
error( "Sorting failed (>pivot)." );
}
/* Try to recurse in parallel. */
if
(
N
<
100
)
{
/* Recurse on the left? */
if
(
j
>
0
&&
pivot
>
min
)
parts_sort
(
parts
,
ind
,
j
+
1
,
min
,
pivot
);
/* Recurse on the right? */
if
(
i
<
N
&&
pivot
+
1
<
max
)
parts_sort
(
&
parts
[
i
],
&
ind
[
i
],
N
-
i
,
pivot
+
1
,
max
);
}
else
// #pragma omp parallel sections
{
} */
/* Recurse on the left? */
// #pragma omp section
if
(
j
>
0
&&
pivot
>
min
)
parts_sort
(
parts
,
ind
,
j
+
1
,
min
,
pivot
);
/* Recurse on the left? */
if
(
j
>
0
&&
pivot
>
min
)
parts_sort
(
parts
,
ind
,
j
+
1
,
min
,
pivot
);
/* Recurse on the right? */
// #pragma omp section
if
(
i
<
N
&&
pivot
+
1
<
max
)
parts_sort
(
&
parts
[
i
],
&
ind
[
i
],
N
-
i
,
pivot
+
1
,
max
);
}
/* Recurse on the right? */
if
(
i
<
N
&&
pivot
+
1
<
max
)
parts_sort
(
&
parts
[
i
],
&
ind
[
i
],
N
-
i
,
pivot
+
1
,
max
);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment