Skip to content
GitLab
Menu
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
fabeb932
Commit
fabeb932
authored
Mar 08, 2016
by
Pedro Gonnet
Browse files
fix and format space.c, forgot one field in space.h.
parent
943b0e1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/space.c
View file @
fabeb932
...
@@ -311,7 +311,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -311,7 +311,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
int
j
,
k
,
cdim
[
3
],
nr_parts
=
s
->
nr_parts
,
nr_gparts
=
s
->
nr_gparts
;
int
j
,
k
,
cdim
[
3
],
nr_parts
=
s
->
nr_parts
,
nr_gparts
=
s
->
nr_gparts
;
struct
cell
*
restrict
c
,
*
restrict
cells
;
struct
cell
*
restrict
c
,
*
restrict
cells
;
struct
part
*
restrict
p
;
struct
part
*
restrict
p
;
in
t
*
ind
;
size_
t
*
ind
;
double
ih
[
3
],
dim
[
3
];
double
ih
[
3
],
dim
[
3
];
ticks
tic
=
getticks
();
ticks
tic
=
getticks
();
...
@@ -324,8 +324,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -324,8 +324,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Run through the particles and get their cell index. */
/* Run through the particles and get their cell index. */
// tic = getticks();
// tic = getticks();
const
in
t
ind_size
=
s
->
size_parts
;
const
size_
t
ind_size
=
s
->
size_parts
;
if
((
ind
=
(
in
t
*
)
malloc
(
sizeof
(
in
t
)
*
ind_size
))
==
NULL
)
if
((
ind
=
(
size_
t
*
)
malloc
(
sizeof
(
size_
t
)
*
ind_size
))
==
NULL
)
error
(
"Failed to allocate temporary particle indices."
);
error
(
"Failed to allocate temporary particle indices."
);
ih
[
0
]
=
s
->
ih
[
0
];
ih
[
0
]
=
s
->
ih
[
0
];
ih
[
1
]
=
s
->
ih
[
1
];
ih
[
1
]
=
s
->
ih
[
1
];
...
@@ -376,10 +376,10 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -376,10 +376,10 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Re-allocate the index array if needed.. */
/* Re-allocate the index array if needed.. */
if
(
s
->
nr_parts
>
ind_size
)
{
if
(
s
->
nr_parts
>
ind_size
)
{
in
t
*
ind_new
;
size_
t
*
ind_new
;
if
((
ind_new
=
(
in
t
*
)
malloc
(
sizeof
(
in
t
)
*
s
->
nr_parts
))
==
NULL
)
if
((
ind_new
=
(
size_
t
*
)
malloc
(
sizeof
(
size_
t
)
*
s
->
nr_parts
))
==
NULL
)
error
(
"Failed to allocate temporary particle indices."
);
error
(
"Failed to allocate temporary particle indices."
);
memcpy
(
ind_new
,
ind
,
sizeof
(
in
t
)
*
nr_parts
);
memcpy
(
ind_new
,
ind
,
sizeof
(
size_
t
)
*
nr_parts
);
free
(
ind
);
free
(
ind
);
ind
=
ind_new
;
ind
=
ind_new
;
}
}
...
@@ -419,7 +419,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -419,7 +419,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Run through the gravity particles and get their cell index. */
/* Run through the gravity particles and get their cell index. */
// tic = getticks();
// tic = getticks();
if
((
ind
=
(
in
t
*
)
malloc
(
sizeof
(
in
t
)
*
s
->
size_gparts
))
==
NULL
)
if
((
ind
=
(
size_
t
*
)
malloc
(
sizeof
(
size_
t
)
*
s
->
size_gparts
))
==
NULL
)
error
(
"Failed to allocate temporary particle indices."
);
error
(
"Failed to allocate temporary particle indices."
);
for
(
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
for
(
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
struct
gpart
*
gp
=
&
s
->
gparts
[
k
];
struct
gpart
*
gp
=
&
s
->
gparts
[
k
];
...
@@ -506,7 +506,7 @@ void space_split(struct space *s, struct cell *cells, int verbose) {
...
@@ -506,7 +506,7 @@ void space_split(struct space *s, struct cell *cells, int verbose) {
* @param verbose Are we talkative ?
* @param verbose Are we talkative ?
*/
*/
void
space_parts_sort
(
struct
space
*
s
,
in
t
*
ind
,
in
t
N
,
int
min
,
int
max
,
void
space_parts_sort
(
struct
space
*
s
,
size_
t
*
ind
,
size_
t
N
,
int
min
,
int
max
,
int
verbose
)
{
int
verbose
)
{
ticks
tic
=
getticks
();
ticks
tic
=
getticks
();
...
@@ -554,7 +554,7 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
...
@@ -554,7 +554,7 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
void
space_do_parts_sort
()
{
void
space_do_parts_sort
()
{
/* Pointers to the sorting data. */
/* Pointers to the sorting data. */
in
t
*
ind
=
space_sort_struct
.
ind
;
size_
t
*
ind
=
space_sort_struct
.
ind
;
struct
part
*
parts
=
space_sort_struct
.
parts
;
struct
part
*
parts
=
space_sort_struct
.
parts
;
struct
xpart
*
xparts
=
space_sort_struct
.
xparts
;
struct
xpart
*
xparts
=
space_sort_struct
.
xparts
;
...
@@ -676,11 +676,12 @@ void space_do_parts_sort() {
...
@@ -676,11 +676,12 @@ void space_do_parts_sort() {
}
/* main loop. */
}
/* main loop. */
}
}
void
space_gparts_sort
(
struct
gpart
*
gparts
,
in
t
*
ind
,
in
t
N
,
int
min
,
void
space_gparts_sort
(
struct
gpart
*
gparts
,
size_
t
*
ind
,
size_
t
N
,
int
min
,
int
max
)
{
int
max
)
{
struct
qstack
{
struct
qstack
{
volatile
int
i
,
j
,
min
,
max
;
volatile
size_t
i
,
j
;
volatile
int
min
,
max
;
volatile
int
ready
;
volatile
int
ready
;
};
};
struct
qstack
*
qstack
;
struct
qstack
*
qstack
;
...
@@ -688,7 +689,8 @@ void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min,
...
@@ -688,7 +689,8 @@ void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min,
volatile
unsigned
int
first
,
last
,
waiting
;
volatile
unsigned
int
first
,
last
,
waiting
;
int
pivot
;
int
pivot
;
int
i
,
ii
,
j
,
jj
,
temp_i
,
qid
;
size_t
i
,
ii
,
j
,
jj
,
temp_i
;
int
qid
;
struct
gpart
temp_p
;
struct
gpart
temp_p
;
/* for ( int k = 0 ; k < N ; k++ )
/* for ( int k = 0 ; k < N ; k++ )
...
@@ -1186,7 +1188,7 @@ struct cell *space_getcell(struct space *s) {
...
@@ -1186,7 +1188,7 @@ struct cell *space_getcell(struct space *s) {
* recursively.
* recursively.
*/
*/
void
space_init
(
struct
space
*
s
,
double
dim
[
3
],
struct
part
*
parts
,
in
t
N
,
void
space_init
(
struct
space
*
s
,
double
dim
[
3
],
struct
part
*
parts
,
size_
t
N
,
int
periodic
,
double
h_max
,
int
verbose
)
{
int
periodic
,
double
h_max
,
int
verbose
)
{
/* Store everything in the space. */
/* Store everything in the space. */
...
...
src/space.h
View file @
fabeb932
...
@@ -114,7 +114,7 @@ struct qstack {
...
@@ -114,7 +114,7 @@ struct qstack {
struct
parallel_sort
{
struct
parallel_sort
{
struct
part
*
parts
;
struct
part
*
parts
;
struct
xpart
*
xparts
;
struct
xpart
*
xparts
;
in
t
*
ind
;
size_
t
*
ind
;
struct
qstack
*
stack
;
struct
qstack
*
stack
;
unsigned
int
stack_size
;
unsigned
int
stack_size
;
volatile
unsigned
int
first
,
last
,
waiting
;
volatile
unsigned
int
first
,
last
,
waiting
;
...
...
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