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
0025151f
Commit
0025151f
authored
Aug 30, 2012
by
Pedro Gonnet
Browse files
make sorting more memory-efficient.
Former-commit-id: 0b8d1b961353602dc0ec66a399cd1c4a7efb8f4c
parent
fa60b920
Changes
1
Hide whitespace changes
Inline
Side-by-side
runner.c
View file @
0025151f
...
...
@@ -882,7 +882,7 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) {
int
j
,
k
,
count
=
c
->
count
;
int
cone
,
ctwo
;
int
i
,
ind
,
off
[
8
],
inds
[
8
],
temp_i
;
float
shift
[
3
];
//
float shift[3];
float
buff
[
8
];
struct
cell
*
temp_c
;
TIMER_TIC
...
...
@@ -997,36 +997,57 @@ void runner_dosort ( struct runner_thread *rt , struct cell *c , int flags ) {
}
/* progeny? */
/* Otherwise, just sort. */
// else {
//
// /* Loop over the different cell axes. */
// for ( j = 0 ; j < 13 ; j++ ) {
//
// /* Has this sort array been flagged? */
// if ( !( flags & (1 << j) ) )
// continue;
//
// /* Get the shift vector. */
// shift[0] = runner_shift[ 3*j + 0 ];
// shift[1] = runner_shift[ 3*j + 1 ];
// shift[2] = runner_shift[ 3*j + 2 ];
//
// /* Fill the sort array. */
// finger = &c->sort[ j*(count + 1) ];
// for ( k = 0 ; k < count ; k++ ) {
// finger[k].i = k;
// finger[k].d = parts[k].x[0]*shift[0] + parts[k].x[1]*shift[1] + parts[k].x[2]*shift[2];
// }
//
// /* Add the sentinel. */
// finger[ c->count ].d = FLT_MAX;
// finger[ c->count ].i = 0;
//
// /* Sort descending. */
// runner_dosort_ascending( finger , c->count );
//
// }
//
// }
/* Otherwise, just sort. */
else
{
/* Loop over the different cell axes. */
for
(
j
=
0
;
j
<
13
;
j
++
)
{
/* Has this sort array been flagged? */
if
(
!
(
flags
&
(
1
<<
j
)
)
)
continue
;
/* Get the shift vector. */
shift
[
0
]
=
runner_shift
[
3
*
j
+
0
];
shift
[
1
]
=
runner_shift
[
3
*
j
+
1
];
shift
[
2
]
=
runner_shift
[
3
*
j
+
2
];
/* Fill the sort array. */
finger
=
&
c
->
sort
[
j
*
(
count
+
1
)
];
for
(
k
=
0
;
k
<
count
;
k
++
)
{
finger
[
k
].
i
=
k
;
finger
[
k
].
d
=
parts
[
k
].
x
[
0
]
*
shift
[
0
]
+
parts
[
k
].
x
[
1
]
*
shift
[
1
]
+
parts
[
k
].
x
[
2
]
*
shift
[
2
];
/* Fill the sort array. */
for
(
k
=
0
;
k
<
count
;
k
++
)
for
(
j
=
0
;
j
<
13
;
j
++
)
if
(
flags
&
(
1
<<
j
)
)
{
c
->
sort
[
j
*
(
count
+
1
)
+
k
].
i
=
k
;
c
->
sort
[
j
*
(
count
+
1
)
+
k
].
d
=
parts
[
k
].
x
[
0
]
*
runner_shift
[
3
*
j
+
0
]
+
parts
[
k
].
x
[
1
]
*
runner_shift
[
3
*
j
+
1
]
+
parts
[
k
].
x
[
2
]
*
runner_shift
[
3
*
j
+
2
];
}
/* Add the sentinel and sort. */
for
(
j
=
0
;
j
<
13
;
j
++
)
if
(
flags
&
(
1
<<
j
)
)
{
c
->
sort
[
j
*
(
count
+
1
)
+
c
->
count
].
d
=
FLT_MAX
;
c
->
sort
[
j
*
(
count
+
1
)
+
c
->
count
].
i
=
0
;
runner_dosort_ascending
(
&
c
->
sort
[
j
*
(
count
+
1
)
]
,
c
->
count
);
}
/* Add the sentinel. */
finger
[
c
->
count
].
d
=
FLT_MAX
;
finger
[
c
->
count
].
i
=
0
;
/* Sort descending. */
runner_dosort_ascending
(
finger
,
c
->
count
);
}
}
...
...
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