Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
12479cbf
Commit
12479cbf
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
allocate space for incomming gparts.
parent
9338f2e4
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!117
Engine exchange strays
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/engine.c
+18
-11
18 additions, 11 deletions
src/engine.c
src/part.h
+1
-0
1 addition, 0 deletions
src/part.h
src/space.h
+2
-0
2 additions, 0 deletions
src/space.h
with
21 additions
and
11 deletions
src/engine.c
+
18
−
11
View file @
12479cbf
...
@@ -545,33 +545,40 @@ void engine_exchange_cells(struct engine *e) {
...
@@ -545,33 +545,40 @@ void engine_exchange_cells(struct engine *e) {
/* Count the number of particles we need to import and re-allocate
/* Count the number of particles we need to import and re-allocate
the buffer if needed. */
the buffer if needed. */
int
count_in
=
0
;
int
count_
parts_in
=
0
,
count_gparts_
in
=
0
;
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
count_in
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
count
;
count_parts_in
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
count
;
if
(
count_in
>
s
->
size_parts_foreign
)
{
count_gparts_in
+=
e
->
proxies
[
k
].
cells_in
[
j
]
->
gcount
;
}
if
(
count_parts_in
>
s
->
size_parts_foreign
)
{
if
(
s
->
parts_foreign
!=
NULL
)
free
(
s
->
parts_foreign
);
if
(
s
->
parts_foreign
!=
NULL
)
free
(
s
->
parts_foreign
);
s
->
size_parts_foreign
=
1
.
1
*
count_in
;
s
->
size_parts_foreign
=
1
.
1
*
count_
parts_
in
;
if
(
posix_memalign
((
void
**
)
&
s
->
parts_foreign
,
part_align
,
if
(
posix_memalign
((
void
**
)
&
s
->
parts_foreign
,
part_align
,
sizeof
(
struct
part
)
*
s
->
size_parts_foreign
)
!=
0
)
sizeof
(
struct
part
)
*
s
->
size_parts_foreign
)
!=
0
)
error
(
"Failed to allocate foreign part data."
);
error
(
"Failed to allocate foreign part data."
);
}
}
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."
);
}
/* Unpack the cells and link to the particle data. */
/* Unpack the cells and link to the particle data. */
struct
part
*
parts
=
s
->
parts_foreign
;
struct
part
*
parts
=
s
->
parts_foreign
;
//
struct gpart *gparts = s->gparts_foreign;
struct
gpart
*
gparts
=
s
->
gparts_foreign
;
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
{
for
(
int
k
=
0
;
k
<
nr_proxies
;
k
++
)
{
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
for
(
int
j
=
0
;
j
<
e
->
proxies
[
k
].
nr_cells_in
;
j
++
)
{
cell_link_parts
(
e
->
proxies
[
k
].
cells_in
[
j
],
parts
);
cell_link_parts
(
e
->
proxies
[
k
].
cells_in
[
j
],
parts
);
//
cell_link_gparts(e->proxies[k].cells_in[j], gparts);
cell_link_gparts
(
e
->
proxies
[
k
].
cells_in
[
j
],
gparts
);
parts
=
&
parts
[
e
->
proxies
[
k
].
cells_in
[
j
]
->
count
];
parts
=
&
parts
[
e
->
proxies
[
k
].
cells_in
[
j
]
->
count
];
gparts
=
&
gparts
[
e
->
proxies
[
k
].
cells_in
[
j
]
->
gcount
];
}
}
}
}
s
->
nr_parts_foreign
=
parts
-
s
->
parts_foreign
;
s
->
nr_parts_foreign
=
parts
-
s
->
parts_foreign
;
s
->
nr_gparts_foreign
=
gparts
-
s
->
gparts_foreign
;
/* Is the parts buffer large enough? */
if
(
s
->
nr_parts_foreign
>
s
->
size_parts_foreign
)
error
(
"Foreign parts buffer too small."
);
/* Free the pcell buffer. */
/* Free the pcell buffer. */
free
(
pcells
);
free
(
pcells
);
...
...
This diff is collapsed.
Click to expand it.
src/part.h
+
1
−
0
View file @
12479cbf
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
/* Some constants. */
/* Some constants. */
#define part_align 64
#define part_align 64
#define xpart_align 32
#define xpart_align 32
#define gpart_align 32
/* Import the right particle definition */
/* Import the right particle definition */
#if defined(MINIMAL_SPH)
#if defined(MINIMAL_SPH)
...
...
This diff is collapsed.
Click to expand it.
src/space.h
+
2
−
0
View file @
12479cbf
...
@@ -106,6 +106,8 @@ struct space {
...
@@ -106,6 +106,8 @@ struct space {
/* Buffers for parts that we will receive from foreign cells. */
/* Buffers for parts that we will receive from foreign cells. */
struct
part
*
parts_foreign
;
struct
part
*
parts_foreign
;
size_t
nr_parts_foreign
,
size_parts_foreign
;
size_t
nr_parts_foreign
,
size_parts_foreign
;
struct
gpart
*
gparts_foreign
;
size_t
nr_gparts_foreign
,
size_gparts_foreign
;
};
};
/* Interval stack necessary for parallel particle sorting. */
/* Interval stack necessary for parallel particle sorting. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment