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
8a60d2cd
Commit
8a60d2cd
authored
Jul 11, 2013
by
Pedro Gonnet
Browse files
xparts are now sorted like parts, no cross-referencing.
Former-commit-id: 9e5b3cf669f8bec0d7d80635fff7c5a569022207
parent
483df2a7
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
8a60d2cd
...
...
@@ -151,6 +151,7 @@ void cell_split ( struct cell *c ) {
int
i
,
j
,
k
;
struct
part
temp
,
*
parts
=
c
->
parts
;
struct
xpart
xtemp
,
*
xparts
=
c
->
xparts
;
int
left
[
8
],
right
[
8
];
double
pivot
[
3
];
...
...
@@ -167,6 +168,7 @@ void cell_split ( struct cell *c ) {
j
-=
1
;
if
(
i
<
j
)
{
temp
=
parts
[
i
];
parts
[
i
]
=
parts
[
j
];
parts
[
j
]
=
temp
;
xtemp
=
xparts
[
i
];
xparts
[
i
]
=
xparts
[
j
];
xparts
[
j
]
=
xtemp
;
}
}
/* for ( k = 0 ; k <= j ; k++ )
...
...
@@ -188,6 +190,7 @@ void cell_split ( struct cell *c ) {
j
-=
1
;
if
(
i
<
j
)
{
temp
=
parts
[
i
];
parts
[
i
]
=
parts
[
j
];
parts
[
j
]
=
temp
;
xtemp
=
xparts
[
i
];
xparts
[
i
]
=
xparts
[
j
];
xparts
[
j
]
=
xtemp
;
}
}
/* for ( int kk = left[k] ; kk <= j ; kk++ )
...
...
@@ -212,6 +215,7 @@ void cell_split ( struct cell *c ) {
j
-=
1
;
if
(
i
<
j
)
{
temp
=
parts
[
i
];
parts
[
i
]
=
parts
[
j
];
parts
[
j
]
=
temp
;
xtemp
=
xparts
[
i
];
xparts
[
i
]
=
xparts
[
j
];
xparts
[
j
]
=
xtemp
;
}
}
/* for ( int kk = left[k] ; kk <= j ; kk++ )
...
...
@@ -232,6 +236,7 @@ void cell_split ( struct cell *c ) {
for
(
k
=
0
;
k
<
8
;
k
++
)
{
c
->
progeny
[
k
]
->
count
=
right
[
k
]
-
left
[
k
]
+
1
;
c
->
progeny
[
k
]
->
parts
=
&
c
->
parts
[
left
[
k
]
];
c
->
progeny
[
k
]
->
xparts
=
&
c
->
xparts
[
left
[
k
]
];
}
/* Verify that _all_ the parts have been assigned to a cell. */
...
...
src/cell.h
View file @
8a60d2cd
...
...
@@ -54,6 +54,9 @@ struct cell {
/* Pointers to the particle data. */
struct
part
*
parts
;
/* Pointers to the extra particle data. */
struct
xpart
*
xparts
;
/* Pointers for the sorted indices. */
struct
entry
*
sort
;
unsigned
int
sorted
;
...
...
src/part.h
View file @
8a60d2cd
...
...
@@ -125,9 +125,6 @@ struct part {
/* Particle ID. */
unsigned
long
long
id
;
/* Pointer to extra particle data. */
struct
xpart
*
xtras
;
}
__attribute__
((
aligned
(
part_align
)));
src/runner.c
View file @
8a60d2cd
...
...
@@ -527,7 +527,7 @@ void runner_dokick2 ( struct runner *r , struct cell *c ) {
float
dt_cfl
,
dt_h_change
,
dt_u_change
,
dt_new
;
float
h_dt
,
u_dt
;
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
xpart
*
restrict
xp
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
TIMER_TIC
...
...
@@ -544,7 +544,7 @@ void runner_dokick2 ( struct runner *r , struct cell *c ) {
__builtin_prefetch
(
&
parts
[
k
+
3
]
,
0
,
1
);
__builtin_prefetch
(
&
parts
[
k
+
3
].
rho_dh
,
0
,
1
);
p
=
&
parts
[
k
];
xp
=
p
->
xtras
;
xp
=
&
xparts
[
k
]
;
/* Get local copies of particle data. */
pdt
=
p
->
dt
;
...
...
@@ -637,7 +637,7 @@ void runner_dokick1 ( struct runner *r , struct cell *c ) {
float
a
[
3
],
v
[
3
],
u
,
u_dt
,
h
,
h_dt
,
v_old
[
3
],
w
,
rho
;
double
x
[
3
],
x_old
[
3
];
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
xpart
*
restrict
xp
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
/* No children? */
if
(
!
c
->
split
)
{
...
...
@@ -660,8 +660,8 @@ void runner_dokick1 ( struct runner *r , struct cell *c ) {
/* Get a handle on the kth particle. */
__builtin_prefetch
(
&
parts
[
k
+
3
]
,
0
,
1
);
__builtin_prefetch
(
&
parts
[
k
+
3
].
rho_dh
,
0
,
1
);
p
=
&
c
->
parts
[
k
];
xp
=
p
->
xtras
;
p
=
&
parts
[
k
];
xp
=
&
xparts
[
k
]
;
/* Load the data locally. */
a
[
0
]
=
p
->
a
[
0
];
a
[
1
]
=
p
->
a
[
1
];
a
[
2
]
=
p
->
a
[
2
];
...
...
src/scheduler.c
View file @
8a60d2cd
...
...
@@ -842,7 +842,7 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid , struct cell *su
/* Check qid. */
if
(
qid
>=
nr_queues
||
qid
<
0
)
error
(
"Bad queue ID."
);
error
(
"Bad queue ID."
);
/* Loop as long as there are tasks... */
while
(
s
->
waiting
>
0
&&
res
==
NULL
)
{
...
...
src/space.c
View file @
8a60d2cd
...
...
@@ -159,6 +159,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
int
i
,
j
,
k
,
cdim
[
3
],
nr_parts
=
s
->
nr_parts
;
struct
cell
*
restrict
c
;
struct
part
*
restrict
finger
,
*
restrict
p
,
*
parts
=
s
->
parts
;
struct
xpart
*
xfinger
,
*
xparts
=
s
->
xparts
;
int
*
ind
;
double
ih
[
3
],
dim
[
3
];
// ticks tic;
...
...
@@ -281,7 +282,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* Sort the parts according to their cells. */
// tic = getticks();
parts_sort
(
parts
,
ind
,
s
->
nr_parts
,
0
,
s
->
nr_cells
-
1
);
parts_sort
(
parts
,
xparts
,
ind
,
s
->
nr_parts
,
0
,
s
->
nr_cells
-
1
);
// printf( "space_rebuild: parts_sort took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
/* Verify sort. */
...
...
@@ -298,11 +299,14 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* Hook the cells up to the parts. */
// tic = getticks();
finger
=
s
->
parts
;
finger
=
parts
;
xfinger
=
xparts
;
for
(
k
=
0
;
k
<
s
->
nr_cells
;
k
++
)
{
c
=
&
s
->
cells
[
k
];
c
->
parts
=
finger
;
c
->
xparts
=
xfinger
;
finger
=
&
finger
[
c
->
count
];
xfinger
=
&
xfinger
[
c
->
count
];
}
// printf( "space_rebuild: hooking up cells took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
...
...
@@ -336,7 +340,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
* @param max highest index.
*/
void
parts_sort
(
struct
part
*
parts
,
int
*
ind
,
int
N
,
int
min
,
int
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
;
...
...
@@ -346,6 +350,7 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
int
pivot
;
int
i
,
ii
,
j
,
jj
,
temp_i
,
qid
;
struct
part
temp_p
;
struct
xpart
temp_xp
;
/* Init the interval stack. */
qstack
[
0
].
i
=
0
;
...
...
@@ -358,7 +363,7 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
first
=
0
;
last
=
1
;
waiting
=
1
;
/* Parallel bit. */
#pragma omp parallel default(shared) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_p)
#pragma omp parallel default(shared) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_
xp,temp_
p)
{
/* Main loop. */
...
...
@@ -398,6 +403,7 @@ void parts_sort ( struct part *parts , int *ind , int N , int min , int max ) {
if
(
ii
<
jj
)
{
temp_i
=
ind
[
ii
];
ind
[
ii
]
=
ind
[
jj
];
ind
[
jj
]
=
temp_i
;
temp_p
=
parts
[
ii
];
parts
[
ii
]
=
parts
[
jj
];
parts
[
jj
]
=
temp_p
;
temp_xp
=
xparts
[
ii
];
xparts
[
ii
]
=
xparts
[
jj
];
xparts
[
jj
]
=
temp_xp
;
}
}
...
...
@@ -632,7 +638,7 @@ void space_split ( struct space *s , struct cell *c ) {
float
h
,
h_max
=
0
.
0
f
,
dt
,
dt_min
=
c
->
parts
[
0
].
dt
,
dt_max
=
dt_min
;
struct
cell
*
temp
;
struct
part
*
p
,
*
parts
=
c
->
parts
;
struct
xpart
*
xp
;
struct
xpart
*
xp
,
*
xparts
=
c
->
xparts
;
/* Check the depth. */
if
(
c
->
depth
>
s
->
maxdepth
)
...
...
@@ -707,7 +713,7 @@ void space_split ( struct space *s , struct cell *c ) {
for
(
k
=
0
;
k
<
count
;
k
++
)
{
p
=
&
parts
[
k
];
xp
=
p
->
xtras
;
xp
=
&
xparts
[
k
]
;
xp
->
x_old
[
0
]
=
p
->
x
[
0
];
xp
->
x_old
[
1
]
=
p
->
x
[
1
];
xp
->
x_old
[
2
]
=
p
->
x
[
2
];
...
...
@@ -835,8 +841,6 @@ struct cell *space_getcell ( struct space *s ) {
void
space_init
(
struct
space
*
s
,
double
dim
[
3
]
,
struct
part
*
parts
,
int
N
,
int
periodic
,
double
h_max
)
{
int
k
;
/* Store eveything in the space. */
s
->
dim
[
0
]
=
dim
[
0
];
s
->
dim
[
1
]
=
dim
[
1
];
s
->
dim
[
2
]
=
dim
[
2
];
s
->
periodic
=
periodic
;
...
...
@@ -845,11 +849,9 @@ void space_init ( struct space *s , double dim[3] , struct part *parts , int N ,
s
->
cell_min
=
h_max
;
s
->
nr_queues
=
1
;
/* Allocate
and link
the xtra parts array. */
/* Allocate the xtra parts array. */
if
(
posix_memalign
(
(
void
*
)
&
s
->
xparts
,
32
,
N
*
sizeof
(
struct
xpart
)
)
!=
0
)
error
(
"Failed to allocate xparts."
);
for
(
k
=
0
;
k
<
N
;
k
++
)
s
->
parts
[
k
].
xtras
=
&
s
->
xparts
[
k
];
/* Init the space lock. */
if
(
lock_init
(
&
s
->
lock
)
!=
0
)
...
...
src/space.h
View file @
8a60d2cd
...
...
@@ -100,7 +100,7 @@ struct space {
/* function prototypes. */
void
parts_sort
(
struct
part
*
parts
,
int
*
ind
,
int
N
,
int
min
,
int
max
);
void
parts_sort
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
int
*
ind
,
int
N
,
int
min
,
int
max
);
struct
cell
*
space_getcell
(
struct
space
*
s
);
int
space_getsid
(
struct
space
*
s
,
struct
cell
**
ci
,
struct
cell
**
cj
,
double
*
shift
);
void
space_init
(
struct
space
*
s
,
double
dim
[
3
]
,
struct
part
*
parts
,
int
N
,
int
periodic
,
double
h_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