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
b7d55874
Commit
b7d55874
authored
Nov 14, 2013
by
Pedro Gonnet
Browse files
don't create gravity tasks when there are no gravity particles.
Former-commit-id: 67aa9f90856740bbfec0f4a0768aefead4ce51c5
parent
a5b63b7b
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
b7d55874
...
...
@@ -41,6 +41,7 @@
/* Local headers. */
#include "const.h"
#include "atomic.h"
#include "cycle.h"
#include "lock.h"
#include "task.h"
...
...
@@ -232,7 +233,7 @@ int cell_locktree( struct cell *c ) {
break
;
/* Increment the hold. */
__sync_fetch_and_add
(
&
finger
->
hold
,
1
);
atomic_inc
(
&
finger
->
hold
);
/* Unlock the cell. */
if
(
lock_unlock
(
&
finger
->
lock
)
!=
0
)
...
...
@@ -475,7 +476,8 @@ void cell_split ( struct cell *c ) {
/* Re-link the gparts. */
for
(
k
=
0
;
k
<
count
;
k
++
)
parts
[
k
].
gpart
->
part
=
&
parts
[
k
];
if
(
parts
[
k
].
gpart
!=
NULL
)
parts
[
k
].
gpart
->
part
=
&
parts
[
k
];
/* Verify that _all_ the parts have been assigned to a cell. */
/* for ( k = 1 ; k < 8 ; k++ )
...
...
src/const.h
View file @
b7d55874
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
* Coypright (c) 2012 Pedro Gonnet (p
tc
edro.gonnet@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
...
...
@@ -44,9 +44,12 @@
/* Gravity stuff. */
#define const_theta_max 0.57735f
/* Opening criteria, which is the ratio of the
cell distance over the cell width. */
#define const_G 6.67384e-8f
/* Gravitational constant. */
#define const_epsilon 0.0014f
/* Gravity blending distance. */
#define const_iepsilon 714.285714286f
/* Inverse gravity blending distance. */
// #define const_G 6.67384e-8f /* Gravitational constant. */
#define const_G 6.672e-8f
/* Gravitational constant. */
// #define const_epsilon 0.0014f /* Gravity blending distance. */
// #define const_iepsilon 714.285714286f /* Inverse gravity blending distance. */
#define const_epsilon 1e-20
#define const_iepsilon 1e20
#define const_iepsilon2 (const_iepsilon*const_iepsilon)
#define const_iepsilon3 (const_iepsilon2*const_iepsilon)
#define const_iepsilon4 (const_iepsilon2*const_iepsilon2)
...
...
src/engine.c
View file @
b7d55874
...
...
@@ -963,11 +963,13 @@ void engine_maketasks ( struct engine *e ) {
}
/* Add the gravity mm tasks. */
for
(
i
=
0
;
i
<
nr_cells
;
i
++
)
{
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
]
,
NULL
,
0
);
for
(
j
=
i
+
1
;
j
<
nr_cells
;
j
++
)
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
]
,
&
cells
[
j
]
,
0
);
}
for
(
i
=
0
;
i
<
nr_cells
;
i
++
)
if
(
cells
[
i
].
gcount
>
0
)
{
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
]
,
NULL
,
0
);
for
(
j
=
i
+
1
;
j
<
nr_cells
;
j
++
)
if
(
cells
[
j
].
gcount
>
0
)
scheduler_addtask
(
sched
,
task_type_grav_mm
,
task_subtype_none
,
-
1
,
0
,
&
cells
[
i
]
,
&
cells
[
j
]
,
0
);
}
/* Split the tasks. */
scheduler_splittasks
(
sched
);
...
...
@@ -981,7 +983,7 @@ void engine_maketasks ( struct engine *e ) {
/* Add the gravity up/down tasks at the top-level cells and push them down. */
for
(
k
=
0
;
k
<
nr_cells
;
k
++
)
if
(
cells
[
k
].
nodeID
==
nodeID
)
{
if
(
cells
[
k
].
nodeID
==
nodeID
&&
cells
[
k
].
gcount
>
0
)
{
/* Create tasks at top level. */
struct
task
*
up
=
scheduler_addtask
(
sched
,
task_type_grav_up
,
task_subtype_none
,
0
,
0
,
&
cells
[
k
]
,
NULL
,
0
);
...
...
@@ -1131,7 +1133,7 @@ void engine_maketasks ( struct engine *e ) {
}
/* Kick2 tasks should rely on the grav_down tasks of their cell. */
else
if
(
t
->
type
==
task_type_kick2
)
else
if
(
t
->
type
==
task_type_kick2
&&
t
->
ci
->
grav_down
!=
NULL
)
scheduler_addunlock
(
sched
,
t
->
ci
->
grav_down
,
t
);
}
...
...
src/part.h
View file @
b7d55874
...
...
@@ -68,7 +68,7 @@ struct gpart {
union
{
/* Particle ID. */
unsigned
long
long
id
;
size_t
id
;
/* Pointer to corresponding SPH part. */
struct
part
*
part
;
...
...
src/queue.c
View file @
b7d55874
...
...
@@ -152,7 +152,7 @@ void queue_init ( struct queue *q , struct task *tasks ) {
struct
task
*
queue_gettask
(
struct
queue
*
q
,
struct
cell
*
super
,
int
blocking
)
{
int
k
,
temp
,
qcount
,
*
qtid
,
gotcha
;
int
k
,
qcount
,
*
qtid
,
gotcha
;
lock_type
*
qlock
=
&
q
->
lock
;
struct
task
*
qtasks
,
*
res
=
NULL
;
...
...
@@ -216,7 +216,8 @@ struct task *queue_gettask ( struct queue *q , struct cell *super , int blocking
/* Swap this task with the last task and re-heap. */
if
(
k
<
qcount
)
{
qtid
[
k
]
=
qtid
[
qcount
];
while
(
qtasks
[
qtid
[
k
]
].
weight
>
qtasks
[
qtid
[(
k
-
1
)
/
2
]
].
weight
)
{
int
w
=
qtasks
[
qtid
[
k
]
].
weight
;
while
(
k
>
0
&&
w
>
qtasks
[
qtid
[(
k
-
1
)
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
q
->
tid
[
k
]
=
q
->
tid
[(
k
-
1
)
/
2
];
q
->
tid
[(
k
-
1
)
/
2
]
=
temp
;
...
...
@@ -226,8 +227,8 @@ struct task *queue_gettask ( struct queue *q , struct cell *super , int blocking
while
(
(
i
=
2
*
k
+
1
)
<
qcount
)
{
if
(
i
+
1
<
qcount
&&
qtasks
[
qtid
[
i
+
1
]
].
weight
>
qtasks
[
qtid
[
i
]
].
weight
)
i
+=
1
;
if
(
qtasks
[
qtid
[
i
]
].
weight
>
qtasks
[
qtid
[
k
]
].
weight
)
{
temp
=
qtid
[
i
];
if
(
qtasks
[
qtid
[
i
]
].
weight
>
w
)
{
int
temp
=
qtid
[
i
];
qtid
[
i
]
=
qtid
[
k
];
qtid
[
k
]
=
temp
;
k
=
i
;
...
...
src/scheduler.c
View file @
b7d55874
...
...
@@ -464,7 +464,7 @@ void scheduler_splittasks ( struct scheduler *s ) {
/* Split this task into tasks on its progeny. */
t
->
type
=
task_type_none
;
for
(
j
=
0
;
j
<
8
;
j
++
)
if
(
ci
->
progeny
[
j
]
!=
NULL
)
{
if
(
ci
->
progeny
[
j
]
!=
NULL
&&
ci
->
progeny
[
j
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
...
...
@@ -473,7 +473,7 @@ void scheduler_splittasks ( struct scheduler *s ) {
else
t
=
scheduler_addtask
(
s
,
task_type_grav_mm
,
task_subtype_none
,
0
,
0
,
ci
->
progeny
[
j
]
,
NULL
,
0
);
for
(
k
=
j
+
1
;
k
<
8
;
k
++
)
if
(
ci
->
progeny
[
k
]
!=
NULL
)
{
if
(
ci
->
progeny
[
k
]
!=
NULL
&&
ci
->
progeny
[
k
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
...
...
@@ -534,9 +534,9 @@ void scheduler_splittasks ( struct scheduler *s ) {
/* Split this task into tasks on its progeny. */
t
->
type
=
task_type_none
;
for
(
j
=
0
;
j
<
8
;
j
++
)
if
(
ci
->
progeny
[
j
]
!=
NULL
)
{
if
(
ci
->
progeny
[
j
]
!=
NULL
&&
ci
->
progeny
[
j
]
->
gcount
>
0
)
{
for
(
k
=
0
;
k
<
8
;
k
++
)
if
(
cj
->
progeny
[
k
]
!=
NULL
)
{
if
(
cj
->
progeny
[
k
]
!=
NULL
&&
cj
->
progeny
[
k
]
->
gcount
>
0
)
{
if
(
t
->
type
==
task_type_none
)
{
t
->
type
=
task_type_grav_mm
;
t
->
ci
=
ci
->
progeny
[
j
];
...
...
src/space.c
View file @
b7d55874
...
...
@@ -1163,7 +1163,7 @@ void space_init ( struct space *s , double dim[3] , struct part *parts , int N ,
if
(
posix_memalign
(
(
void
*
)
&
s
->
gparts
,
part_align
,
N
*
sizeof
(
struct
gpart
)
)
!=
0
)
error
(
"Failed to allocate gparts."
);
bzero
(
s
->
gparts
,
N
*
sizeof
(
struct
gpart
)
);
for
(
int
k
=
0
;
k
<
N
;
k
++
)
{
/*
for ( int k = 0 ; k < N ; k++ ) {
s->gparts[k].x[0] = s->parts[k].x[0];
s->gparts[k].x[1] = s->parts[k].x[1];
s->gparts[k].x[2] = s->parts[k].x[2];
...
...
@@ -1176,7 +1176,8 @@ void space_init ( struct space *s , double dim[3] , struct part *parts , int N ,
s->gparts[k].part = &s->parts[k];
s->parts[k].gpart = &s->gparts[k];
}
s
->
nr_gparts
=
s
->
nr_parts
;
s->nr_gparts = s->nr_parts; */
s
->
nr_gparts
=
0
;
s
->
size_gparts
=
s
->
size_parts
;
...
...
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