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
85e95820
Commit
85e95820
authored
Jan 11, 2019
by
Matthieu Schaller
Browse files
Also link the foreign sparts.
parent
7fa7547e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
85e95820
...
...
@@ -102,7 +102,7 @@ int cell_link_parts(struct cell *c, struct part *parts) {
if
(
c
->
nodeID
==
engine_rank
)
error
(
"Linking foreign particles in a local cell!"
);
if
(
c
->
hydro
.
parts
!=
NULL
)
if
(
c
->
hydro
.
parts
!=
NULL
)
error
(
"Linking parts into a cell that was already linked"
);
#endif
...
...
@@ -135,7 +135,7 @@ int cell_link_gparts(struct cell *c, struct gpart *gparts) {
if
(
c
->
nodeID
==
engine_rank
)
error
(
"Linking foreign particles in a local cell!"
);
if
(
c
->
grav
.
parts
!=
NULL
)
if
(
c
->
grav
.
parts
!=
NULL
)
error
(
"Linking gparts into a cell that was already linked"
);
#endif
...
...
@@ -168,7 +168,7 @@ int cell_link_sparts(struct cell *c, struct spart *sparts) {
if
(
c
->
nodeID
==
engine_rank
)
error
(
"Linking foreign particles in a local cell!"
);
if
(
c
->
stars
.
parts
!=
NULL
)
if
(
c
->
stars
.
parts
!=
NULL
)
error
(
"Linking sparts into a cell that was already linked"
);
#endif
...
...
@@ -303,7 +303,6 @@ int cell_count_gparts_for_tasks(const struct cell *c) {
}
}
/**
* @brief Pack the data of the given cell and all it's sub-cells.
*
...
...
src/engine.c
View file @
85e95820
...
...
@@ -1756,30 +1756,33 @@ void engine_allocate_foreign_particles(struct engine *e) {
const
int
nr_proxies
=
e
->
nr_proxies
;
struct
space
*
s
=
e
->
s
;
//
ticks tic = getticks();
ticks
tic
=
getticks
();
/* Count the number of particles we need to import and re-allocate
the buffer if needed. */
size_t
count_parts_in_old
=
0
,
count_gparts_in_old
=
0
;
size_t
count_parts_in
=
0
,
count_gparts_in
=
0
;
size_t
count_parts_in
=
0
,
count_gparts_in
=
0
,
count_sparts_in
=
0
;
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
{
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
if
(
e
->
proxies
[
k
].
cells_in_type
[
j
]
&
proxy_cell_type_hydro
)
{
count_parts_in_old
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
hydro
.
count
;
count_parts_in
+=
cell_count_parts_for_tasks
(
e
->
proxies
[
k
].
cells_in
[
j
]);
}
if
(
e
->
proxies
[
k
].
cells_in_type
[
j
]
&
proxy_cell_type_gravity
)
{
count_gparts_in
_old
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
grav
.
count
;
count_gparts_in
+=
cell_count_gparts_for_tasks
(
e
->
proxies
[
k
].
cells_in
[
j
]);
count_gparts_in
+=
cell_count_gparts_for_tasks
(
e
->
proxies
[
k
].
cells_in
[
j
]);
}
/* For stars, we just use the numbers in the top-level cells */
count_sparts_in
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
stars
.
count
;
}
}
message
(
"New parts count: %zd old parts count: %zd"
,
count_parts_in
,
count_parts_in_old
);
message
(
"New gparts count: %zd old gparts count: %zd"
,
count_gparts_in
,
count_gparts_in_old
);
if
(
e
->
verbose
)
message
(
"Counting number of foreign particles took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
tic
=
getticks
();
/* Allocate space for the foreign particles we will receive */
if
(
count_parts_in
>
s
->
size_parts_foreign
)
{
...
...
@@ -1797,90 +1800,56 @@ void engine_allocate_foreign_particles(struct engine *e) {
sizeof
(
struct
gpart
)
*
s
->
size_gparts_foreign
)
!=
0
)
error
(
"Failed to allocate foreign gpart data."
);
}
/* Allocate space for the foreign particles we will receive */
if
(
count_sparts_in
>
s
->
size_sparts_foreign
)
{
if
(
s
->
sparts_foreign
!=
NULL
)
free
(
s
->
sparts_foreign
);
s
->
size_sparts_foreign
=
1
.
1
*
count_sparts_in
;
if
(
posix_memalign
((
void
**
)
&
s
->
sparts_foreign
,
part_align
,
sizeof
(
struct
spart
)
*
s
->
size_sparts_foreign
)
!=
0
)
error
(
"Failed to allocate foreign spart data."
);
}
if
(
e
->
verbose
)
message
(
"Allocating memory for foreign particles took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
tic
=
getticks
();
/* Unpack the cells and link to the particle data. */
struct
part
*
parts
=
s
->
parts_foreign
;
struct
gpart
*
gparts
=
s
->
gparts_foreign
;
size_t
total_count_parts
=
0
;
size_t
total_count_gparts
=
0
;
struct
spart
*
sparts
=
s
->
sparts_foreign
;
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
{
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
if
(
e
->
proxies
[
k
].
cells_in_type
[
j
]
&
proxy_cell_type_hydro
)
{
const
size_t
count_parts
=
cell_link_foreign_parts
(
e
->
proxies
[
k
].
cells_in
[
j
],
parts
);
const
size_t
count_parts
=
cell_link_foreign_parts
(
e
->
proxies
[
k
].
cells_in
[
j
],
parts
);
parts
=
&
parts
[
count_parts
];
total_count_parts
+=
count_parts
;
}
if
(
e
->
proxies
[
k
].
cells_in_type
[
j
]
&
proxy_cell_type_gravity
)
{
const
size_t
count_gparts
=
cell_link_foreign_gparts
(
e
->
proxies
[
k
].
cells_in
[
j
],
gparts
);
const
size_t
count_gparts
=
cell_link_foreign_gparts
(
e
->
proxies
[
k
].
cells_in
[
j
],
gparts
);
gparts
=
&
gparts
[
count_gparts
];
total_count_gparts
+=
count_gparts
;
}
/* For stars, we just use the numbers in the top-level cells */
cell_link_sparts
(
e
->
proxies
[
k
].
cells_in
[
j
],
sparts
);
sparts
=
&
sparts
[
e
->
proxies
[
k
].
cells_in
[
j
]
->
stars
.
count
];
}
}
/* Update the counters */
s
->
nr_parts_foreign
=
parts
-
s
->
parts_foreign
;
s
->
nr_gparts_foreign
=
gparts
-
s
->
gparts_foreign
;
s
->
nr_sparts_foreign
=
sparts
-
s
->
sparts_foreign
;
message
(
"count_parts: %zd %zd"
,
count_parts_in
,
total_count_parts
);
return
;
/* if (count_gparts_in > s->size_gparts_foreign) { */
/* if (s->gparts_foreign != NULL) free(s->gparts_foreign); */
/* s->size_gparts_foreign = 1.1 * count_gparts_in; */
/* if (posix_memalign((void **)&s->gparts_foreign, gpart_align, */
/* sizeof(struct gpart) * s->size_gparts_foreign) != 0)
*/
/* error("Failed to allocate foreign gpart data."); */
/* } */
/* if (count_sparts_in > s->size_sparts_foreign) { */
/* if (s->sparts_foreign != NULL) free(s->sparts_foreign); */
/* s->size_sparts_foreign = 1.1 * count_sparts_in; */
/* if (posix_memalign((void **)&s->sparts_foreign, spart_align, */
/* sizeof(struct spart) * s->size_sparts_foreign) != 0)
*/
/* error("Failed to allocate foreign spart data."); */
/* } */
/* if (e->verbose) */
/* message("Counting and allocating arrays took %.3f %s.", */
/* clocks_from_ticks(getticks() - tic), clocks_getunit()); */
/* tic = getticks(); */
/* /\* Unpack the cells and link to the particle data. *\/ */
/* struct part *parts = s->parts_foreign; */
/* struct gpart *gparts = s->gparts_foreign; */
/* struct spart *sparts = s->sparts_foreign; */
/* for (int k = 0; k < nr_proxies; k++) { */
/* for (int j = 0; j < e->proxies[k].nr_cells_in; j++) { */
/* if (e->proxies[k].cells_in_type[j] & proxy_cell_type_hydro) { */
/* cell_link_parts(e->proxies[k].cells_in[j], parts); */
/* parts = &parts[e->proxies[k].cells_in[j]->hydro.count]; */
/* } */
/* if (e->proxies[k].cells_in_type[j] & proxy_cell_type_gravity) { */
/* cell_link_gparts(e->proxies[k].cells_in[j], gparts); */
/* gparts = &gparts[e->proxies[k].cells_in[j]->grav.count]; */
/* } */
/* cell_link_sparts(e->proxies[k].cells_in[j], sparts); */
/* sparts = &sparts[e->proxies[k].cells_in[j]->stars.count]; */
/* } */
/* } */
/* s->nr_parts_foreign = parts - s->parts_foreign; */
/* s->nr_gparts_foreign = gparts - s->gparts_foreign; */
/* s->nr_sparts_foreign = sparts - s->sparts_foreign; */
/* if (e->verbose) */
/* message("Recursively linking arrays took %.3f %s.", */
/* clocks_from_ticks(getticks() - tic), clocks_getunit()); */
if
(
e
->
verbose
)
message
(
"Recursively linking arrays took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
#else
error
(
"SWIFT was not compiled with MPI support."
);
...
...
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